PHP Trait Webiny\Component\StdLib\StdObject\ArrayObject\ValidatorTrait

Show file Open project: Webiny/Framework

Public Methods

Method Description
inArray ( mixed $value, boolean $strict = false ) : boolean | key Search the array for the given $value.
keyExists ( string | StringObject $key, mixed $default = false ) : boolean | mixed Checks if $key exists in current array as index. If it exists, true is returned.
keyExistsNested ( string | StringObject $key, mixed $default = false ) : boolean | mixed Checks if $key exists in current array as index. If it exists, true is returned.
keysExist ( array $keys = [] ) : boolean Check if all given keys exist in the array

Method Details

inArray() public method

If $strict is true, both values must be of the same instance type.
public inArray ( mixed $value, boolean $strict = false ) : boolean | key
$value mixed
$strict boolean
return boolean | key Returns the key under which the $value is found, or false.

keyExists() public method

If the $key doesn't exist, $default is returned,
public keyExists ( string | StringObject $key, mixed $default = false ) : boolean | mixed
$key string | Webiny\Component\StdLib\StdObject\StringObject\StringObject Array key.
$default mixed If key is not found, $default is returned.
return boolean | mixed True is returned if the key exists, otherwise $default is returned.

keyExistsNested() public method

If the $key doesn't exist, $default is returned. This method supports nested keys access: 'level1.level2.level3'
public keyExistsNested ( string | StringObject $key, mixed $default = false ) : boolean | mixed
$key string | Webiny\Component\StdLib\StdObject\StringObject\StringObject Array key. Eg: 'level1.level2.level3'
$default mixed If key is not found, $default is returned.
return boolean | mixed True is returned if the key exists, otherwise $default is returned.

keysExist() public method

Check if all given keys exist in the array
public keysExist ( array $keys = [] ) : boolean
$keys array
return boolean