public function pluck( $property, $ifEmptyDefaultToContainer = false )
    {

        $mapper = $this->getPropertyMapper($property);
        $isAllObjects = true;

        $output = [];
        foreach( $this->collection as $obj ) {
            $propertyValue = $mapper->get($obj);
            $isAllObjects = $isAllObjects and is_object($propertyValue);
            $output[] = $propertyValue;
        }
        if( $output ) {
            if( $isAllObjects ) {
                try {
                    return new Container($output);
                } catch ( \Exception $e ) {
                }
            }
        } elseif( $ifEmptyDefaultToContainer) {
            return new Container();
        }
        return $output;

    }
public function pluck( $property, $ifEmptyDefaultToContainer = false )
    {

        $mapper = $this->getPropertyMapper($property);
        $isAllObjects = true;

        $output = [];
        foreach( $this->collection as $obj ) {
            $propertyValue = $mapper->get($obj);
            $isAllObjects = $isAllObjects and is_object($propertyValue);
            $output[] = $propertyValue;
        }
        if( $output ) {
            if( $isAllObjects ) {
                try {
                    return new Container($output);
                } catch ( \Exception $e ) {
                }
            }
        } elseif( $ifEmptyDefaultToContainer) {
            return new Container();
        }
        return $output;

    }
public function pluck ( $ property , $ ifEmptyDefaultToContainer = false ) { $ mapper = $ this -> getPropertyMapper ( $ property ) ; $ isAllObjects = true ; $ output = [ ] ; foreach ( $ this -> collection as $ obj ) { $ propertyValue = $ mapper -> get ( $ obj ) ; $ isAllObjects = $ isAllObjects and is_object ( $ propertyValue ) ; $ output [ ] = $ propertyValue ; } if ( $ output ) { if ( $ isAllObjects ) { try { return new Container ( $ output ) ; } catch ( \ Exception $ e ) { } } } elseif ( $ ifEmptyDefaultToContainer ) { return new Container ( ) ; } return $ output ; }
Pluck a property from the collection
@param string Property
@return mixed Bond\Container | mixed[]
Pluck a property from the collection