Exemple #1
0
 function test_pluck_object_values()
 {
     $array = array(new AccessObjPropStub('Packers', 'Brewers', 'Bucks'), new AccessObjPropStub('summer', 'fall', 'winter'));
     $expected = array('Packers', 'summer');
     $this->assertEquals($expected, Arr::pluck($array, 'foo'));
     $this->assertEquals($expected, wpdevsclub_array_pluck($array, 'foo'));
     $expected = array('Bucks' => 'Packers', 'winter' => 'summer');
     $this->assertEquals($expected, Arr::pluck($array, 'foo', 'baz'));
     $this->assertEquals($expected, wpdevsclub_array_pluck($array, 'foo', 'baz'));
     $array = array(new AccessObjPropStub(array('name' => 'Tonya', 'email' => 'foo'), 'Brewers', 'Bucks'), new AccessObjPropStub(array('name' => 'Julie', 'email' => 'bar'), 'fall', 'winter'), new AccessObjPropStub('summer', 'fall', 'winter'));
     $expected = array('Tonya', 'Julie');
     $this->assertEquals($expected, Arr::pluck($array, 'foo.name'));
     $this->assertEquals($expected, wpdevsclub_array_pluck($array, 'foo.name'));
 }
 /**
  * Get an array with the values of a given key.
  *
  * @param  string  $value
  * @param  string  $key
  * @return array
  */
 public function lists($value, $key = null)
 {
     return wpdevsclub_array_pluck($this->items, $value, $key);
 }