keys() public method

Returns an array of all keys in the collection
public keys ( ) : array
return array
 public function test_getting_array_of_keys()
 {
     $coll = new Collection();
     $coll->addItem('Test Item', 1);
     $coll->addItem('Test Item', 2);
     $actual = $coll->keys();
     $expected = array(1, 2);
     $this->assertEquals($expected, $actual);
 }
Example #2
0
 public function __construct(Collection $collection)
 {
     $this->collection = $collection;
     $this->keys = $collection->keys();
 }
 public function testKeys()
 {
     $collection = new Collection(['1', 'b' => '2']);
     $this->assertSame([0, 'b'], $collection->keys());
 }
Example #4
0
 /**
  *
  * @param Collection $collection
  */
 public function __construct(JsonManager $collection)
 {
     $this->collection = $collection;
     $this->keys = $this->collection->keys();
 }