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;
    }
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;
    }
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 ; }
Return one and one only object from a collection
@throws ConstraintException if there are zero or >1 objects
Return one and one only object from a collection