Pheasant\Collection::one PHP Method

one() public method

Return one and one only object from a collection
public one ( )
    public function one()
    {
        $object = $this->offsetGet(0);
        // execute after the query so we save a query
        $count = $this->count();
        if ($count === 0) {
            throw new NotFoundException("Expected 1 element, found 0");
        } elseif ($count > 1) {
            throw new ConstraintException("Expected only 1 element, found {$count}");
        }
        return $object;
    }