public function test() { $collection = new Collection([new Entity(['id' => 1]), new Entity(['id' => 1]), new Entity(['id' => 1]), new Entity(['id' => 2]), new Entity(['id' => 3])]); $collection->distinctOn('id'); $this->assertEquals([['id' => 1], ['id' => 2], ['id' => 3]], $collection->toArray()); }