for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace WS\Utils\Collections\Functions\Group\Aggregator;
use WS\Utils\Collections\Collection;
use WS\Utils\Collections\Functions\ObjectFunctions;
class Last
{
private $fieldName;
public function __construct(string $fieldName)
$this->fieldName = $fieldName;
}
public function __invoke(Collection $collection)
if (!$last = $collection->stream()->findLast()) {
return null;
return ObjectFunctions::getPropertyValue($last, $this->fieldName);