| @@ -76,9 +76,9 @@ | ||
| 76 | 76 | * |
| 77 | 77 | * @return bool |
| 78 | 78 | */ |
| 79 | 79 | public static function is_valid_version( $version ) { |
| 80 | - return (bool) preg_match( '/^(\d+\.)?(\d+\.)?(\*|\d+)(-.+)?$/', $version ); | |
| 80 | + return ! ! preg_match( '/^(\d+\.)?(\d+\.)?(\*|\d+)(-.+)?$/', $version ); | |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * Creates a Version instance from a string. |
| @@ -86,13 +86,13 @@ | ||
| 86 | 86 | * @param $version |
| 87 | 87 | * @param bool $should_validate |
| 88 | 88 | * |
| 89 | 89 | * @return static |
| 90 | - * @throws \Exception If version comparison fails or invalid version format is provided. | |
| 90 | + * @throws \Exception | |
| 91 | 91 | */ |
| 92 | 92 | public static function create_from_string( $version, $should_validate = true ) { |
| 93 | 93 | if ( $should_validate && ! static::is_valid_version( $version ) ) { |
| 94 | - throw new \Exception( sprintf( '%s is an invalid version.', esc_html( $version ) ) ); | |
| 94 | + throw new \Exception( "{$version} is an invalid version." ); | |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | $parts = explode( '.', $version ); |
| 98 | 98 | $patch_parts = []; |
| @@ -130,9 +130,9 @@ | ||
| 130 | 130 | * @param $version |
| 131 | 131 | * @param string $part |
| 132 | 132 | * |
| 133 | 133 | * @return bool |
| 134 | - * @throws \Exception If version validation fails or parsing errors occur. | |
| 134 | + * @throws \Exception | |
| 135 | 135 | */ |
| 136 | 136 | public function compare( $operator, $version, $part = self::PART_STAGE ) { |
| 137 | 137 | if ( ! ( $version instanceof Version ) ) { |
| 138 | 138 | if ( ! static::is_valid_version( $version ) ) { |