min() public method

Get the min value of a given key.
public min ( callable | string | null $callback = null ) : mixed
$callback callable | string | null
return mixed
Example #1
0
 public function testGettingMinItemsFromCollection()
 {
     $c = new Collection([(object) ['foo' => 10], (object) ['foo' => 20]]);
     $this->assertEquals(10, $c->min('foo'));
     $c = new Collection([['foo' => 10], ['foo' => 20]]);
     $this->assertEquals(10, $c->min('foo'));
     $c = new Collection([1, 2, 3, 4, 5]);
     $this->assertEquals(1, $c->min());
     $c = new Collection();
     $this->assertNull($c->min());
 }