| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPSEO plugin file. |
| 4 |
* |
| 5 |
* @package WPSEO\Internals |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Class WPSEO_Validator. |
| 10 |
* |
| 11 |
* @deprecated 15.6 |
| 12 |
*/ |
| 13 |
class WPSEO_Validator { |
| 14 |
|
| 15 |
/** |
| 16 |
* Validates whether the passed variable is a boolean. |
| 17 |
* |
| 18 |
* @deprecated 15.6 |
| 19 |
* @codeCoverageIgnore |
| 20 |
* |
| 21 |
* @param mixed $variable The variable to validate. |
| 22 |
* |
| 23 |
* @return bool Whether or not the passed variable is a valid boolean. |
| 24 |
*/ |
| 25 |
public static function is_boolean( $variable ) { |
| 26 |
_deprecated_function( __METHOD__, 'WPSEO 15.6' ); |
| 27 |
|
| 28 |
if ( is_bool( $variable ) ) { |
| 29 |
return true; |
| 30 |
} |
| 31 |
|
| 32 |
return filter_var( $variable, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ) !== null; |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Validates whether the passed variable is a string. |
| 37 |
* |
| 38 |
* @deprecated 15.6 |
| 39 |
* @codeCoverageIgnore |
| 40 |
* |
| 41 |
* @param mixed $variable The variable to validate. |
| 42 |
* |
| 43 |
* @return bool Whether or not the passed variable is a string. |
| 44 |
*/ |
| 45 |
public static function is_string( $variable ) { |
| 46 |
_deprecated_function( __METHOD__, 'WPSEO 15.6' ); |
| 47 |
|
| 48 |
return is_string( $variable ); |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Validates whether the passed variable is a non-empty string. |
| 53 |
* |
| 54 |
* @deprecated 15.6 |
| 55 |
* @codeCoverageIgnore |
| 56 |
* |
| 57 |
* @param mixed $variable The variable to validate. |
| 58 |
* |
| 59 |
* @return bool Whether or not the passed value is a non-empty string. |
| 60 |
*/ |
| 61 |
public static function is_non_empty_string( $variable ) { |
| 62 |
_deprecated_function( __METHOD__, 'WPSEO 15.6' ); |
| 63 |
|
| 64 |
return self::is_string( $variable ) && $variable !== ''; |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* Validates whether the passed variable is an integer. |
| 69 |
* |
| 70 |
* @deprecated 15.6 |
| 71 |
* @codeCoverageIgnore |
| 72 |
* |
| 73 |
* @param mixed $variable The variable to validate. |
| 74 |
* |
| 75 |
* @return bool Whether or not the passed variable is an integer. |
| 76 |
*/ |
| 77 |
public static function is_integer( $variable ) { |
| 78 |
_deprecated_function( __METHOD__, 'WPSEO 15.6' ); |
| 79 |
|
| 80 |
return filter_var( $variable, FILTER_VALIDATE_INT ) || filter_var( $variable, FILTER_VALIDATE_INT ) === 0; |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* Determines whether a particular key exists within the passed dataset. |
| 85 |
* |
| 86 |
* @deprecated 15.6 |
| 87 |
* @codeCoverageIgnore |
| 88 |
* |
| 89 |
* @param array $data The dataset to search through. |
| 90 |
* @param string $key The key to search for. |
| 91 |
* |
| 92 |
* @return bool Whether or not the key exists. |
| 93 |
*/ |
| 94 |
public static function key_exists( array $data, $key ) { |
| 95 |
_deprecated_function( __METHOD__, 'WPSEO 15.6' ); |
| 96 |
|
| 97 |
return array_key_exists( $key, $data ); |
| 98 |
} |
| 99 |
} |
| 100 |
|