class-autoloader-handler.php
1 month ago
class-autoloader-locator.php
1 month ago
class-autoloader.php
1 month ago
class-container.php
1 month ago
class-hook-manager.php
1 month ago
class-latest-autoloader-guard.php
1 month ago
class-manifest-reader.php
1 month ago
class-path-processor.php
1 month ago
class-php-autoloader.php
1 month ago
class-plugin-locator.php
1 month ago
class-plugins-handler.php
1 month ago
class-shutdown-handler.php
1 month ago
class-version-loader.php
1 month ago
class-version-selector.php
1 month ago
class-version-selector.php
70 lines
| 1 | <?php |
| 2 | /** |
| 3 | * This file was automatically generated by automattic/jetpack-autoloader. |
| 4 | * |
| 5 | * @package automattic/jetpack-autoloader |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\Jetpack\Autoloader\jpb362f03b12b29b02131a59d9d1231943\al5_0_15; |
| 9 | |
| 10 | // phpcs:ignore |
| 11 | |
| 12 | /** |
| 13 | * Used to select package versions. |
| 14 | */ |
| 15 | class Version_Selector { |
| 16 | |
| 17 | /** |
| 18 | * Checks whether the selected package version should be updated. Composer development |
| 19 | * package versions ('9999999-dev' or versions that start with 'dev-') are favored |
| 20 | * when the JETPACK_AUTOLOAD_DEV constant is set to true. |
| 21 | * |
| 22 | * @param String $selected_version The currently selected package version. |
| 23 | * @param String $compare_version The package version that is being evaluated to |
| 24 | * determine if the version needs to be updated. |
| 25 | * |
| 26 | * @return bool Returns true if the selected package version should be updated, |
| 27 | * else false. |
| 28 | */ |
| 29 | public function is_version_update_required( $selected_version, $compare_version ) { |
| 30 | $use_dev_versions = defined( 'JETPACK_AUTOLOAD_DEV' ) && JETPACK_AUTOLOAD_DEV; |
| 31 | |
| 32 | if ( $selected_version === null ) { |
| 33 | return true; |
| 34 | } |
| 35 | |
| 36 | if ( $use_dev_versions && $this->is_dev_version( $selected_version ) ) { |
| 37 | return false; |
| 38 | } |
| 39 | |
| 40 | if ( $this->is_dev_version( $compare_version ) ) { |
| 41 | if ( $use_dev_versions ) { |
| 42 | return true; |
| 43 | } else { |
| 44 | return false; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | if ( version_compare( $selected_version, $compare_version, '<' ) ) { |
| 49 | return true; |
| 50 | } |
| 51 | |
| 52 | return false; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Checks whether the given package version is a development version. |
| 57 | * |
| 58 | * @param String $version The package version. |
| 59 | * |
| 60 | * @return bool True if the version is a dev version, else false. |
| 61 | */ |
| 62 | public function is_dev_version( $version ) { |
| 63 | if ( 'dev-' === substr( $version, 0, 4 ) || '9999999-dev' === $version ) { |
| 64 | return true; |
| 65 | } |
| 66 | |
| 67 | return false; |
| 68 | } |
| 69 | } |
| 70 |