PHP Class GraphQL\Utils

Mostra file Open project: webonyx/graphql-php Class Usage Examples

Public Methods

Method Description
assign ( object $obj, array $vars, array $requiredKeys = [] ) : array
charCodeAt ( $string, $position ) : mixed Returns UTF-8 char code at given $positing of the $string
chr ( string $ord, string $encoding = 'UTF-8' ) : string UTF-8 compatible chr()
each ( $traversable, callable $fn )
every ( $traversable, callable $predicate ) : boolean
filter ( $traversable, callable $predicate ) : array
find ( array | Traversabl\Traversable $traversable, callable $predicate ) : null
getVariableType ( $var ) : string
groupBy ( $traversable, callable $keyFn ) : array Splits original traversable to several arrays with keys equal to $keyFn return
invariant ( $test, string $message = '' )
keyMap ( $traversable, callable $keyFn ) : array
map ( array | Traversable $traversable, callable $fn ) : array
mapKeyValue ( $traversable, callable $fn ) : array
ord ( string $char, string $encoding = 'UTF-8' ) : mixed UTF-8 compatible ord()
printCharCode ( $code ) : string
printSafe ( $var ) : string
undefined ( )

Method Details

assign() public static method

public static assign ( object $obj, array $vars, array $requiredKeys = [] ) : array
$obj object
$vars array
$requiredKeys array
return array

charCodeAt() public static method

Returns UTF-8 char code at given $positing of the $string
public static charCodeAt ( $string, $position ) : mixed
$string
$position
return mixed

chr() public static method

UTF-8 compatible chr()
public static chr ( string $ord, string $encoding = 'UTF-8' ) : string
$ord string
$encoding string
return string

each() public static method

public static each ( $traversable, callable $fn )
$traversable
$fn callable

every() public static method

public static every ( $traversable, callable $predicate ) : boolean
$traversable
$predicate callable
return boolean

filter() public static method

public static filter ( $traversable, callable $predicate ) : array
$traversable
$predicate callable
return array

find() public static method

public static find ( array | Traversabl\Traversable $traversable, callable $predicate ) : null
$traversable array | Traversabl\Traversable
$predicate callable
return null

getVariableType() public static method

public static getVariableType ( $var ) : string
$var
return string

groupBy() public static method

E.g. Utils::groupBy([1, 2, 3, 4, 5], function($value) {return $value % 3}) will output: [ 1 => [1, 4], 2 => [2, 5], 0 => [3], ] $keyFn is also allowed to return array of keys. Then value will be added to all arrays with given keys
public static groupBy ( $traversable, callable $keyFn ) : array
$traversable
$keyFn callable function($value, $key) => $newKey(s)
return array

invariant() public static method

public static invariant ( $test, string $message = '' )
$test
$message string

keyMap() public static method

public static keyMap ( $traversable, callable $keyFn ) : array
$traversable
$keyFn callable function($value, $key) => $newKey
return array

map() public static method

public static map ( array | Traversable $traversable, callable $fn ) : array
$traversable array | Traversable
$fn callable function($value, $key) => $newValue
return array

mapKeyValue() public static method

public static mapKeyValue ( $traversable, callable $fn ) : array
$traversable
$fn callable
return array

ord() public static method

UTF-8 compatible ord()
public static ord ( string $char, string $encoding = 'UTF-8' ) : mixed
$char string
$encoding string
return mixed

printCharCode() public static method

public static printCharCode ( $code ) : string
$code
return string

printSafe() public static method

public static printSafe ( $var ) : string
$var
return string

undefined() public static method

public static undefined ( )