<?php $requirements = new class { public function minimum_php_version( float $version ): self { if ( version_compare( phpversion(), $version, '<' ) ) { throw new Exception( sprintf( "You need PHP version %s to run this plugin.", $version ) ); } return $this; } public function require_plugins(array $plugins): self { // Logic return $this; } }; try { $requirements ->minimum_php_version(8.0) ->require_plugins( ['bar.php', 'baz/baz.php'] ); } catch ( Exception $e ) { var_dump( $e->getMessage() ); }
You have javascript disabled. You will not be able to edit any code.