getValue() public static method

public static getValue ( mixed $object, string $field, null | mixed $default = null, boolean $accessPrivate = false ) : mixed | null
$object mixed
$field string
$default null | mixed
$accessPrivate boolean
return mixed | null
 public function __get($field)
 {
     $this->_operations[] = function ($input) use($field) {
         return Objects::getValue($input, $field);
     };
     return $this;
 }
Beispiel #2
0
 /**
  * @test
  */
 public function shouldReturnValueFormArray()
 {
     //given
     $array = array('id' => 123, 'name' => 'John');
     //when
     $value = Objects::getValue($array, 'name');
     //then
     $this->assertEquals('John', $value);
 }
Beispiel #3
0
 public static function extractField($name, $accessPrivate = false)
 {
     return function ($object) use($name, $accessPrivate) {
         return Objects::getValue($object, $name, null, $accessPrivate);
     };
 }