LMongo\Eloquent\Collection::add PHP Method

add() public method

Add an item to the collection.
public add ( mixed $item ) : Collection
$item mixed
return Collection
    public function add($item)
    {
        $this->items[] = $item;
        return $this;
    }

Usage Example

 public function testContainsIndicatesIfKeyedModelInArray()
 {
     $mockModel = m::mock('LMongo\\Eloquent\\Model');
     $mockModel->shouldReceive('getKey')->andReturn(1);
     $c = new Collection(array($mockModel));
     $mockModel2 = m::mock('LMongo\\Eloquent\\Model');
     $mockModel2->shouldReceive('getKey')->andReturn(2);
     $c->add($mockModel2);
     $this->assertTrue($c->contains(1));
     $this->assertTrue($c->contains(2));
     $this->assertFalse($c->contains(3));
 }