Assert\Assertion::keyIsset PHP Метод

keyIsset() публичный статический Метод

Assert that key exists in an array/array-accessible object using isset()
public static keyIsset ( mixed $value, string | integer $key, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$key string | integer
$message string | null
$propertyPath string | null
Результат boolean
    public static function keyIsset($value, $key, $message = null, $propertyPath = null)
    {
        static::isArrayAccessible($value, $message, $propertyPath);
        if (!isset($value[$key])) {
            $message = sprintf($message ?: 'The element with key "%s" was not found', static::stringify($key));
            throw static::createException($value, $message, static::INVALID_KEY_ISSET, $propertyPath, array('key' => $key));
        }
        return true;
    }

Usage Example

Пример #1
0
 /**
  * @param string $location
  *
  * @return static
  */
 public static function fromString($location)
 {
     Assertion::string($location);
     $result = explode('.', $location);
     Assertion::keyIsset($result, 0);
     Assertion::keyIsset($result, 1);
     return new static((int) $result[0], (int) $result[1]);
 }
All Usage Examples Of Assert\Assertion::keyIsset