@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | * |
| 188 | 188 | * @since 0.1.0 |
| 189 | 189 | * |
| 190 | - * @return int The patch version that is used. '' if not defined. |
|
| 190 | + * @return string The patch version that is used. '' if not defined. |
|
| 191 | 191 | */ |
| 192 | 192 | public function get_pre_release() { |
| 193 | 193 | return (string) $this->get_component( 'pre-release' ) ?: ''; |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * |
| 199 | 199 | * @since 0.1.0 |
| 200 | 200 | * |
| 201 | - * @return int The build metadata for the version that is used. '' if not |
|
| 201 | + * @return string The build metadata for the version that is used. '' if not |
|
| 202 | 202 | * defined. |
| 203 | 203 | */ |
| 204 | 204 | public function get_build() { |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * SemanticVersion Class |
|
| 4 | - * |
|
| 5 | - * @package phpfeature |
|
| 6 | - * @author Alain Schlesser <[email protected]> |
|
| 7 | - * @license GPL-2.0+ |
|
| 8 | - * @link http://www.brightnucleus.com/ |
|
| 9 | - * @copyright 2016 Alain Schlesser, Bright Nucleus |
|
| 10 | - */ |
|
| 3 | + * SemanticVersion Class |
|
| 4 | + * |
|
| 5 | + * @package phpfeature |
|
| 6 | + * @author Alain Schlesser <[email protected]> |
|
| 7 | + * @license GPL-2.0+ |
|
| 8 | + * @link http://www.brightnucleus.com/ |
|
| 9 | + * @copyright 2016 Alain Schlesser, Bright Nucleus |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * Class SemanticVersion |
@@ -58,13 +58,13 @@ discard block |
||
| 58 | 58 | * throwing an exception. |
| 59 | 59 | * @throws RuntimeException When the version fails to validate. |
| 60 | 60 | */ |
| 61 | - public function __construct( $version = null, $partial = false ) { |
|
| 61 | + public function __construct($version = null, $partial = false) { |
|
| 62 | 62 | |
| 63 | - if ( ! $version ) { |
|
| 63 | + if ( ! $version) { |
|
| 64 | 64 | $version = '0.0.0'; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $version = $this->validate( $version, $partial ); |
|
| 67 | + $version = $this->validate($version, $partial); |
|
| 68 | 68 | |
| 69 | 69 | $this->version = $version; |
| 70 | 70 | } |
@@ -81,33 +81,33 @@ discard block |
||
| 81 | 81 | * @return string |
| 82 | 82 | * @throws RuntimeException When the version fails to validate. |
| 83 | 83 | */ |
| 84 | - protected function validate( $version, $partial = false ) { |
|
| 84 | + protected function validate($version, $partial = false) { |
|
| 85 | 85 | |
| 86 | - $version = trim( $version ); |
|
| 86 | + $version = trim($version); |
|
| 87 | 87 | $pattern = self::VERSION_PATTERN; |
| 88 | 88 | |
| 89 | 89 | $components = array(); |
| 90 | - $result = preg_match( $pattern, $version, $components ); |
|
| 90 | + $result = preg_match($pattern, $version, $components); |
|
| 91 | 91 | |
| 92 | - if ( ! $result ) { |
|
| 93 | - throw new RuntimeException( sprintf( |
|
| 92 | + if ( ! $result) { |
|
| 93 | + throw new RuntimeException(sprintf( |
|
| 94 | 94 | 'Failed to validate version "%1$s".', |
| 95 | 95 | (string) $version |
| 96 | - ) ); |
|
| 96 | + )); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if ( ! $partial && ( ! isset( $components[2] ) || ! isset( $components[3] ) ) ) { |
|
| 100 | - throw new RuntimeException( sprintf( |
|
| 99 | + if ( ! $partial && ( ! isset($components[2]) || ! isset($components[3]))) { |
|
| 100 | + throw new RuntimeException(sprintf( |
|
| 101 | 101 | 'Could not accept partial version "%1$s", requested full versions only.', |
| 102 | 102 | (string) $version |
| 103 | - ) ); |
|
| 103 | + )); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - $this->set_component( 'major', isset( $components[1] ) ? (int) $components[1] : 0 ); |
|
| 107 | - $this->set_component( 'minor', isset( $components[2] ) ? (int) $components[2] : 0 ); |
|
| 108 | - $this->set_component( 'patch', isset( $components[3] ) ? (int) $components[3] : 0 ); |
|
| 109 | - $this->set_component( 'pre-release', isset( $components[4] ) ? (string) $components[4] : '' ); |
|
| 110 | - $this->set_component( 'build', isset( $components[5] ) ? (string) $components[5] : '' ); |
|
| 106 | + $this->set_component('major', isset($components[1]) ? (int) $components[1] : 0); |
|
| 107 | + $this->set_component('minor', isset($components[2]) ? (int) $components[2] : 0); |
|
| 108 | + $this->set_component('patch', isset($components[3]) ? (int) $components[3] : 0); |
|
| 109 | + $this->set_component('pre-release', isset($components[4]) ? (string) $components[4] : ''); |
|
| 110 | + $this->set_component('build', isset($components[5]) ? (string) $components[5] : ''); |
|
| 111 | 111 | |
| 112 | 112 | $version = $this->get_version_from_components(); |
| 113 | 113 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * @return string The version that is used. '0.0.0' if not defined. |
| 123 | 123 | */ |
| 124 | 124 | public function get_version() { |
| 125 | - return (string) isset( $this->version ) ? $this->version : '0.0.0'; |
|
| 125 | + return (string) isset($this->version) ? $this->version : '0.0.0'; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | protected function get_version_from_components() { |
| 136 | 136 | |
| 137 | - $pre_release = $this->get_pre_release() ? '-' . $this->get_pre_release() : ''; |
|
| 138 | - $build = $this->get_build() ? '+' . $this->get_build() : ''; |
|
| 137 | + $pre_release = $this->get_pre_release() ? '-'.$this->get_pre_release() : ''; |
|
| 138 | + $build = $this->get_build() ? '+'.$this->get_build() : ''; |
|
| 139 | 139 | |
| 140 | 140 | $version = sprintf( |
| 141 | 141 | '%1$s.%2$s.%3$s%4$s%5$s', |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @return int The major version that is used. 0 if not defined. |
| 158 | 158 | */ |
| 159 | 159 | public function get_major() { |
| 160 | - return (int) $this->get_component( 'major' ) ?: 0; |
|
| 160 | + return (int) $this->get_component('major') ?: 0; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @return int The minor version that is used. 0 if not defined. |
| 169 | 169 | */ |
| 170 | 170 | public function get_minor() { |
| 171 | - return (int) $this->get_component( 'minor' ) ?: 0; |
|
| 171 | + return (int) $this->get_component('minor') ?: 0; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | * @return int The patch version that is used. 0 if not defined. |
| 180 | 180 | */ |
| 181 | 181 | public function get_patch() { |
| 182 | - return (int) $this->get_component( 'patch' ) ?: 0; |
|
| 182 | + return (int) $this->get_component('patch') ?: 0; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * @return int The patch version that is used. '' if not defined. |
| 191 | 191 | */ |
| 192 | 192 | public function get_pre_release() { |
| 193 | - return (string) $this->get_component( 'pre-release' ) ?: ''; |
|
| 193 | + return (string) $this->get_component('pre-release') ?: ''; |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | /** |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * defined. |
| 203 | 203 | */ |
| 204 | 204 | public function get_build() { |
| 205 | - return (string) $this->get_component( 'build' ) ?: ''; |
|
| 205 | + return (string) $this->get_component('build') ?: ''; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
@@ -214,9 +214,9 @@ discard block |
||
| 214 | 214 | * 'major', 'minor', 'patch' |
| 215 | 215 | * @return int The requested version component. null if not defined. |
| 216 | 216 | */ |
| 217 | - protected function get_component( $level ) { |
|
| 218 | - return array_key_exists( $level, $this->components ) |
|
| 219 | - ? $this->components[ $level ] |
|
| 217 | + protected function get_component($level) { |
|
| 218 | + return array_key_exists($level, $this->components) |
|
| 219 | + ? $this->components[$level] |
|
| 220 | 220 | : null; |
| 221 | 221 | } |
| 222 | 222 | |
@@ -229,8 +229,8 @@ discard block |
||
| 229 | 229 | * 'major', 'minor', 'patch' |
| 230 | 230 | * @param int $version What version to set that component to. |
| 231 | 231 | */ |
| 232 | - protected function set_component( $level, $version ) { |
|
| 233 | - $this->components[ $level ] = $version; |
|
| 232 | + protected function set_component($level, $version) { |
|
| 233 | + $this->components[$level] = $version; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Config Class. |
|
| 4 | - * |
|
| 5 | - * @package phpfeature |
|
| 6 | - * @author Alain Schlesser <[email protected]> |
|
| 7 | - * @license GPL-2.0+ |
|
| 8 | - * @link http://www.brightnucleus.com/ |
|
| 9 | - * @copyright 2016 Alain Schlesser, Bright Nucleus |
|
| 10 | - */ |
|
| 3 | + * Config Class. |
|
| 4 | + * |
|
| 5 | + * @package phpfeature |
|
| 6 | + * @author Alain Schlesser <[email protected]> |
|
| 7 | + * @license GPL-2.0+ |
|
| 8 | + * @link http://www.brightnucleus.com/ |
|
| 9 | + * @copyright 2016 Alain Schlesser, Bright Nucleus |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * Config loader used to load config PHP files as objects. |
@@ -25,9 +25,9 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @param array $config Array with settings. |
| 27 | 27 | */ |
| 28 | - public function __construct( array $config ) { |
|
| 28 | + public function __construct(array $config) { |
|
| 29 | 29 | // Make sure the config entries can be accessed as properties. |
| 30 | - parent::__construct( $config, ArrayObject::ARRAY_AS_PROPS ); |
|
| 30 | + parent::__construct($config, ArrayObject::ARRAY_AS_PROPS); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -42,12 +42,12 @@ discard block |
||
| 42 | 42 | * @return mixed |
| 43 | 43 | * @throws BadMethodCallException |
| 44 | 44 | */ |
| 45 | - public function __call( $function, $arguments ) { |
|
| 46 | - if ( ! is_callable( $function ) || substr( $function, 0, 6 ) !== 'array_' ) { |
|
| 47 | - throw new BadMethodCallException( __CLASS__ . '->' . $function ); |
|
| 45 | + public function __call($function, $arguments) { |
|
| 46 | + if ( ! is_callable($function) || substr($function, 0, 6) !== 'array_') { |
|
| 47 | + throw new BadMethodCallException(__CLASS__.'->'.$function); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - return call_user_func_array( $function, array_merge( array( $this->getArrayCopy() ), $arguments ) ); |
|
| 50 | + return call_user_func_array($function, array_merge(array($this->getArrayCopy()), $arguments)); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | * @param string $key The key to check the existence for. |
| 59 | 59 | * @return bool |
| 60 | 60 | */ |
| 61 | - public function has_key( $key ) { |
|
| 62 | - return array_key_exists( $key, (array) $this ); |
|
| 61 | + public function has_key($key) { |
|
| 62 | + return array_key_exists($key, (array) $this); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | * @param string $key The key to get the value for. |
| 71 | 71 | * @return mixed |
| 72 | 72 | */ |
| 73 | - public function get_key( $key ) { |
|
| 74 | - return $this[ $key ]; |
|
| 73 | + public function get_key($key) { |
|
| 74 | + return $this[$key]; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -81,6 +81,6 @@ discard block |
||
| 81 | 81 | * @return mixed |
| 82 | 82 | */ |
| 83 | 83 | public function get_keys() { |
| 84 | - return array_keys( (array) $this ); |
|
| 84 | + return array_keys((array) $this); |
|
| 85 | 85 | } |
| 86 | 86 | } |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * ConfigInterface Interface. |
|
| 4 | - * |
|
| 5 | - * @package phpfeature |
|
| 6 | - * @author Alain Schlesser <[email protected]> |
|
| 7 | - * @license GPL-2.0+ |
|
| 8 | - * @link http://www.brightnucleus.com/ |
|
| 9 | - * @copyright 2016 Alain Schlesser, Bright Nucleus |
|
| 10 | - */ |
|
| 3 | + * ConfigInterface Interface. |
|
| 4 | + * |
|
| 5 | + * @package phpfeature |
|
| 6 | + * @author Alain Schlesser <[email protected]> |
|
| 7 | + * @license GPL-2.0+ |
|
| 8 | + * @link http://www.brightnucleus.com/ |
|
| 9 | + * @copyright 2016 Alain Schlesser, Bright Nucleus |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * Interface ConfigInterface |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return bool |
| 42 | 42 | */ |
| 43 | - public function has_key( $key ); |
|
| 43 | + public function has_key($key); |
|
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * Get the value of a specific key. |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @return mixed |
| 53 | 53 | */ |
| 54 | - public function get_key( $key ); |
|
| 54 | + public function get_key($key); |
|
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * Get the an array with all the keys |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * FeatureInterface Interface |
|
| 4 | - * |
|
| 5 | - * @package phpfeature |
|
| 6 | - * @author Alain Schlesser <[email protected]> |
|
| 7 | - * @license GPL-2.0+ |
|
| 8 | - * @link http://www.brightnucleus.com/ |
|
| 9 | - * @copyright 2016 Alain Schlesser, Bright Nucleus |
|
| 10 | - */ |
|
| 3 | + * FeatureInterface Interface |
|
| 4 | + * |
|
| 5 | + * @package phpfeature |
|
| 6 | + * @author Alain Schlesser <[email protected]> |
|
| 7 | + * @license GPL-2.0+ |
|
| 8 | + * @link http://www.brightnucleus.com/ |
|
| 9 | + * @copyright 2016 Alain Schlesser, Bright Nucleus |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * Interface FeatureInterface |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @param string|array $features What features to check the support of. |
| 31 | 31 | * @return bool |
| 32 | 32 | */ |
| 33 | - public function is_supported( $features ); |
|
| 33 | + public function is_supported($features); |
|
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * Get the minimum required version that supports all of the requested |
@@ -46,5 +46,5 @@ discard block |
||
| 46 | 46 | * @param string|array $features What features to check the support of. |
| 47 | 47 | * @return SemanticVersion|bool |
| 48 | 48 | */ |
| 49 | - public function get_minimum_required( $features ); |
|
| 49 | + public function get_minimum_required($features); |
|
| 50 | 50 | } |
| 51 | 51 | \ No newline at end of file |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * PHPFeature Class |
|
| 4 | - * |
|
| 5 | - * @package phpfeature |
|
| 6 | - * @author Alain Schlesser <[email protected]> |
|
| 7 | - * @license GPL-2.0+ |
|
| 8 | - * @link http://www.brightnucleus.com/ |
|
| 9 | - * @copyright 2016 Alain Schlesser, Bright Nucleus |
|
| 10 | - */ |
|
| 3 | + * PHPFeature Class |
|
| 4 | + * |
|
| 5 | + * @package phpfeature |
|
| 6 | + * @author Alain Schlesser <[email protected]> |
|
| 7 | + * @license GPL-2.0+ |
|
| 8 | + * @link http://www.brightnucleus.com/ |
|
| 9 | + * @copyright 2016 Alain Schlesser, Bright Nucleus |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * Class PHPFeature |
@@ -58,25 +58,25 @@ discard block |
||
| 58 | 58 | * features. |
| 59 | 59 | * @throws RuntimeException If the PHP version could not be validated. |
| 60 | 60 | */ |
| 61 | - public function __construct( $php_version = null, ConfigInterface $config = null ) { |
|
| 61 | + public function __construct($php_version = null, ConfigInterface $config = null) { |
|
| 62 | 62 | |
| 63 | 63 | // TODO: Better way to bootstrap this while still allowing DI? |
| 64 | - if ( ! $config ) { |
|
| 65 | - $config = new Config( include( __DIR__ . '/../config/known_features.php' ) ); |
|
| 64 | + if ( ! $config) { |
|
| 65 | + $config = new Config(include(__DIR__.'/../config/known_features.php')); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | $this->config = $config; |
| 69 | 69 | |
| 70 | - if ( null === $php_version ) { |
|
| 70 | + if (null === $php_version) { |
|
| 71 | 71 | $php_version = phpversion(); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if ( is_integer( $php_version ) ) { |
|
| 74 | + if (is_integer($php_version)) { |
|
| 75 | 75 | $php_version = (string) $php_version; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if ( is_string( $php_version ) ) { |
|
| 79 | - $php_version = new SemanticVersion( $php_version, true ); |
|
| 78 | + if (is_string($php_version)) { |
|
| 79 | + $php_version = new SemanticVersion($php_version, true); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | $this->version = $php_version; |
@@ -97,24 +97,24 @@ discard block |
||
| 97 | 97 | * in. |
| 98 | 98 | * @throws RuntimeException If a requirement could not be parsed. |
| 99 | 99 | */ |
| 100 | - public function is_supported( $features ) { |
|
| 100 | + public function is_supported($features) { |
|
| 101 | 101 | |
| 102 | - if ( is_string( $features ) ) { |
|
| 103 | - $features = array( $features ); |
|
| 102 | + if (is_string($features)) { |
|
| 103 | + $features = array($features); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - if ( ! is_array( $features ) ) { |
|
| 107 | - throw new InvalidArgumentException( sprintf( |
|
| 106 | + if ( ! is_array($features)) { |
|
| 107 | + throw new InvalidArgumentException(sprintf( |
|
| 108 | 108 | 'Wrong type of argument passed in to is_supported(): "%1$s".', |
| 109 | - gettype( $features ) |
|
| 110 | - ) ); |
|
| 109 | + gettype($features) |
|
| 110 | + )); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | $is_supported = true; |
| 114 | 114 | |
| 115 | - while ( $is_supported && count( $features ) > 0 ) { |
|
| 116 | - $feature = array_pop( $features ); |
|
| 117 | - $is_supported &= (bool) $this->check_support( $feature ); |
|
| 115 | + while ($is_supported && count($features) > 0) { |
|
| 116 | + $feature = array_pop($features); |
|
| 117 | + $is_supported &= (bool) $this->check_support($feature); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | return (bool) $is_supported; |
@@ -137,28 +137,28 @@ discard block |
||
| 137 | 137 | * in. |
| 138 | 138 | * @throws RuntimeException If a requirement could not be parsed. |
| 139 | 139 | */ |
| 140 | - public function get_minimum_required( $features ) { |
|
| 140 | + public function get_minimum_required($features) { |
|
| 141 | 141 | |
| 142 | - if ( is_string( $features ) ) { |
|
| 143 | - $features = array( $features ); |
|
| 142 | + if (is_string($features)) { |
|
| 143 | + $features = array($features); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - if ( ! is_array( $features ) ) { |
|
| 147 | - throw new InvalidArgumentException( sprintf( |
|
| 146 | + if ( ! is_array($features)) { |
|
| 147 | + throw new InvalidArgumentException(sprintf( |
|
| 148 | 148 | 'Wrong type of argument passed in to get_minimum_required(): "%1$s".', |
| 149 | - gettype( $features ) |
|
| 150 | - ) ); |
|
| 149 | + gettype($features) |
|
| 150 | + )); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | $minimum_required = '0.0.0'; |
| 154 | 154 | $is_supported = true; |
| 155 | 155 | |
| 156 | - while ( count( $features ) > 0 ) { |
|
| 157 | - $feature = array_pop( $features ); |
|
| 158 | - $is_supported &= (bool) $this->check_support( $feature, $minimum_required ); |
|
| 156 | + while (count($features) > 0) { |
|
| 157 | + $feature = array_pop($features); |
|
| 158 | + $is_supported &= (bool) $this->check_support($feature, $minimum_required); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - return $minimum_required !== '0.0.0' ? new SemanticVersion( $minimum_required, true ) : false; |
|
| 161 | + return $minimum_required !== '0.0.0' ? new SemanticVersion($minimum_required, true) : false; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -172,23 +172,23 @@ discard block |
||
| 172 | 172 | * @return bool |
| 173 | 173 | * @throws RuntimeException If the requirement could not be parsed. |
| 174 | 174 | */ |
| 175 | - protected function check_support( $feature, &$minimum_required = null ) { |
|
| 175 | + protected function check_support($feature, &$minimum_required = null) { |
|
| 176 | 176 | |
| 177 | - if ( ! $this->config->has_key( $feature ) ) { |
|
| 177 | + if ( ! $this->config->has_key($feature)) { |
|
| 178 | 178 | return false; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - $requirements = $this->config->get_key( $feature ); |
|
| 181 | + $requirements = $this->config->get_key($feature); |
|
| 182 | 182 | |
| 183 | - if ( ! is_array( $requirements ) ) { |
|
| 184 | - $requirements = array( $requirements ); |
|
| 183 | + if ( ! is_array($requirements)) { |
|
| 184 | + $requirements = array($requirements); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | $is_supported = true; |
| 188 | 188 | |
| 189 | - while ( ( $is_supported || $minimum_required ) && count( $requirements ) > 0 ) { |
|
| 190 | - $requirement = array_pop( $requirements ); |
|
| 191 | - $is_supported &= (bool) $this->check_requirement( $requirement, $minimum_required ); |
|
| 189 | + while (($is_supported || $minimum_required) && count($requirements) > 0) { |
|
| 190 | + $requirement = array_pop($requirements); |
|
| 191 | + $is_supported &= (bool) $this->check_requirement($requirement, $minimum_required); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | return (bool) $is_supported; |
@@ -206,29 +206,29 @@ discard block |
||
| 206 | 206 | * @return bool |
| 207 | 207 | * @throws RuntimeException If the requirement could not be parsed. |
| 208 | 208 | */ |
| 209 | - protected function check_requirement( $requirement, &$minimum_required = null ) { |
|
| 209 | + protected function check_requirement($requirement, &$minimum_required = null) { |
|
| 210 | 210 | |
| 211 | - $requirement = trim( $requirement ); |
|
| 211 | + $requirement = trim($requirement); |
|
| 212 | 212 | $pattern = self::COMPARISON_PATTERN; |
| 213 | 213 | |
| 214 | 214 | $arguments = array(); |
| 215 | - $result = preg_match( $pattern, $requirement, $arguments ); |
|
| 215 | + $result = preg_match($pattern, $requirement, $arguments); |
|
| 216 | 216 | |
| 217 | - if ( ! $result || ! isset( $arguments[1] ) || ! isset( $arguments[2] ) ) { |
|
| 218 | - throw new RuntimeException( sprintf( |
|
| 217 | + if ( ! $result || ! isset($arguments[1]) || ! isset($arguments[2])) { |
|
| 218 | + throw new RuntimeException(sprintf( |
|
| 219 | 219 | 'Could not parse the requirement "%1$s".', |
| 220 | 220 | (string) $requirement |
| 221 | - ) ); |
|
| 221 | + )); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - $operator = isset( $arguments[1] ) ? (string) $arguments[1] : '>='; |
|
| 225 | - $milestone = isset( $arguments[2] ) ? (string) $arguments[2] : '0.0.0'; |
|
| 224 | + $operator = isset($arguments[1]) ? (string) $arguments[1] : '>='; |
|
| 225 | + $milestone = isset($arguments[2]) ? (string) $arguments[2] : '0.0.0'; |
|
| 226 | 226 | |
| 227 | - $is_supported = (bool) version_compare( $this->version->get_version(), $milestone, $operator ); |
|
| 227 | + $is_supported = (bool) version_compare($this->version->get_version(), $milestone, $operator); |
|
| 228 | 228 | |
| 229 | - if ( $minimum_required ) { |
|
| 230 | - $required_version = $this->get_required_version( $milestone, $operator ); |
|
| 231 | - if ( version_compare( $required_version, $minimum_required, '>' ) ) { |
|
| 229 | + if ($minimum_required) { |
|
| 230 | + $required_version = $this->get_required_version($milestone, $operator); |
|
| 231 | + if (version_compare($required_version, $minimum_required, '>')) { |
|
| 232 | 232 | $minimum_required = $required_version; |
| 233 | 233 | } |
| 234 | 234 | } |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * 'ne' |
| 250 | 250 | * @return string |
| 251 | 251 | */ |
| 252 | - protected function get_required_version( $milestone, $operator ) { |
|
| 252 | + protected function get_required_version($milestone, $operator) { |
|
| 253 | 253 | |
| 254 | 254 | // TODO: Algorithm is still missing, the `$operator` is simply ignored |
| 255 | 255 | // and the pure `$milestone` is returned. |