Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wordpres.../vendor/yoast/whip/src
File: VersionRequirement.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WHIPv2;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WHIPv2\Exceptions\EmptyProperty;
[4] Fix | Delete
use Yoast\WHIPv2\Exceptions\InvalidOperatorType;
[5] Fix | Delete
use Yoast\WHIPv2\Exceptions\InvalidType;
[6] Fix | Delete
use Yoast\WHIPv2\Exceptions\InvalidVersionComparisonString;
[7] Fix | Delete
use Yoast\WHIPv2\Interfaces\Requirement;
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* A value object containing a version requirement for a component version.
[11] Fix | Delete
*/
[12] Fix | Delete
class VersionRequirement implements Requirement {
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* The component name.
[16] Fix | Delete
*
[17] Fix | Delete
* @var string
[18] Fix | Delete
*/
[19] Fix | Delete
private $component;
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* The component version.
[23] Fix | Delete
*
[24] Fix | Delete
* @var string
[25] Fix | Delete
*/
[26] Fix | Delete
private $version;
[27] Fix | Delete
[28] Fix | Delete
/**
[29] Fix | Delete
* The operator to use when comparing version.
[30] Fix | Delete
*
[31] Fix | Delete
* @var string
[32] Fix | Delete
*/
[33] Fix | Delete
private $operator;
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* Requirement constructor.
[37] Fix | Delete
*
[38] Fix | Delete
* @param string $component The component name.
[39] Fix | Delete
* @param string $version The component version.
[40] Fix | Delete
* @param string $operator The operator to use when comparing version.
[41] Fix | Delete
*/
[42] Fix | Delete
public function __construct( $component, $version, $operator = '=' ) {
[43] Fix | Delete
$this->validateParameters( $component, $version, $operator );
[44] Fix | Delete
[45] Fix | Delete
$this->component = $component;
[46] Fix | Delete
$this->version = $version;
[47] Fix | Delete
$this->operator = $operator;
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
/**
[51] Fix | Delete
* Retrieves the component name defined for the requirement.
[52] Fix | Delete
*
[53] Fix | Delete
* @return string The component name.
[54] Fix | Delete
*/
[55] Fix | Delete
public function component() {
[56] Fix | Delete
return $this->component;
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* Gets the components version defined for the requirement.
[61] Fix | Delete
*
[62] Fix | Delete
* @return string
[63] Fix | Delete
*/
[64] Fix | Delete
public function version() {
[65] Fix | Delete
return $this->version;
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* Gets the operator to use when comparing version numbers.
[70] Fix | Delete
*
[71] Fix | Delete
* @return string The comparison operator.
[72] Fix | Delete
*/
[73] Fix | Delete
public function operator() {
[74] Fix | Delete
return $this->operator;
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
/**
[78] Fix | Delete
* Creates a new version requirement from a comparison string.
[79] Fix | Delete
*
[80] Fix | Delete
* @param string $component The component for this version requirement.
[81] Fix | Delete
* @param string $comparisonString The comparison string for this version requirement.
[82] Fix | Delete
*
[83] Fix | Delete
* @return VersionRequirement The parsed version requirement.
[84] Fix | Delete
*
[85] Fix | Delete
* @throws InvalidVersionComparisonString When an invalid version comparison string is passed.
[86] Fix | Delete
*/
[87] Fix | Delete
public static function fromCompareString( $component, $comparisonString ) {
[88] Fix | Delete
[89] Fix | Delete
$matcher = '`
[90] Fix | Delete
(
[91] Fix | Delete
>=? # Matches >= and >.
[92] Fix | Delete
|
[93] Fix | Delete
<=? # Matches <= and <.
[94] Fix | Delete
)
[95] Fix | Delete
([^>=<\s]+) # Matches anything except >, <, =, and whitespace.
[96] Fix | Delete
`x';
[97] Fix | Delete
[98] Fix | Delete
if ( ! \preg_match( $matcher, $comparisonString, $match ) ) {
[99] Fix | Delete
throw new InvalidVersionComparisonString( $comparisonString );
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
$version = $match[2];
[103] Fix | Delete
$operator = $match[1];
[104] Fix | Delete
[105] Fix | Delete
return new VersionRequirement( $component, $version, $operator );
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
/**
[109] Fix | Delete
* Validates the parameters passed to the requirement.
[110] Fix | Delete
*
[111] Fix | Delete
* @param string $component The component name.
[112] Fix | Delete
* @param string $version The component version.
[113] Fix | Delete
* @param string $operator The operator to use when comparing version.
[114] Fix | Delete
*
[115] Fix | Delete
* @return void
[116] Fix | Delete
*
[117] Fix | Delete
* @throws EmptyProperty When any of the parameters is empty.
[118] Fix | Delete
* @throws InvalidOperatorType When the $operator parameter is invalid.
[119] Fix | Delete
* @throws InvalidType When any of the parameters is not of the expected type.
[120] Fix | Delete
*/
[121] Fix | Delete
private function validateParameters( $component, $version, $operator ) {
[122] Fix | Delete
if ( empty( $component ) ) {
[123] Fix | Delete
throw new EmptyProperty( 'Component' );
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
if ( ! \is_string( $component ) ) {
[127] Fix | Delete
throw new InvalidType( 'Component', $component, 'string' );
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
if ( empty( $version ) ) {
[131] Fix | Delete
throw new EmptyProperty( 'Version' );
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
if ( ! \is_string( $version ) ) {
[135] Fix | Delete
throw new InvalidType( 'Version', $version, 'string' );
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
if ( empty( $operator ) ) {
[139] Fix | Delete
throw new EmptyProperty( 'Operator' );
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
if ( ! \is_string( $operator ) ) {
[143] Fix | Delete
throw new InvalidType( 'Operator', $operator, 'string' );
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
$validOperators = array( '=', '==', '===', '<', '>', '<=', '>=' );
[147] Fix | Delete
if ( ! \in_array( $operator, $validOperators, true ) ) {
[148] Fix | Delete
throw new InvalidOperatorType( $operator, $validOperators );
[149] Fix | Delete
}
[150] Fix | Delete
}
[151] Fix | Delete
}
[152] Fix | Delete
[153] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function