lib/Face/Traits/EntityFaceTrait.php
public function faceGetter($needle)
    {
        
        // look the type of $needle then dispatch
        if ( $needle instanceof \Face\Core\EntityFaceElement ) {
            /*  if is already a face element, dont beed anymore work */
            $element=$needle;
        } else if (is_string($needle)) {
            /*
             * if it is a string the string can be the name of the element or a chain of elements separated by a dot
             * e.g 
             *  - first form : "elementName"
             *  - secnd form : "elementName1.elementName2.elementName3"
             */
            // TODO catch "this.elementName" case for dont instanciate a Navigator not needed for performances
            if (false!==strpos($needle, ".")) {
                return (new Navigator($needle))->chainGet($this); // "elementName1.elementName2.elementName3" case
            } else {
                $element=$this->getEntityFace()->getElement($needle); // "elementName" case
            }
        } else {
            throw new BadParameterException("Variable of type '".gettype($needle)."' is not a valide type for faceGetter");
        }


        // if has a getter, it can be a custom callable annonymous function, or the name of the the method to call on this object
        if ($element->hasGetter()) {
            $getter = $element->getGetter();
            if (is_string($getter)) {
//method of this object
                return $this->$getter();
            } elseif (is_callable($getter)) {
// custom callable
                return $getter();
            } else {
                throw new \Exception('Getter is set but it is not usable : '.var_export($getter, true));
            }
        
        // else we use the property directly
        } else {
            $property = $element->getPropertyName();
            return $this->$property;
            
        }
        
        // TODO throw exception on no way to get element
    }
public function faceGetter($needle)
    {
        
        // look the type of $needle then dispatch
        if ( $needle instanceof \Face\Core\EntityFaceElement ) {
            /*  if is already a face element, dont beed anymore work */
            $element=$needle;
        } else if (is_string($needle)) {
            /*
             * if it is a string the string can be the name of the element or a chain of elements separated by a dot
             * e.g 
             *  - first form : "elementName"
             *  - secnd form : "elementName1.elementName2.elementName3"
             */
            // TODO catch "this.elementName" case for dont instanciate a Navigator not needed for performances
            if (false!==strpos($needle, ".")) {
                return (new Navigator($needle))->chainGet($this); // "elementName1.elementName2.elementName3" case
            } else {
                $element=$this->getEntityFace()->getElement($needle); // "elementName" case
            }
        } else {
            throw new BadParameterException("Variable of type '".gettype($needle)."' is not a valide type for faceGetter");
        }


        // if has a getter, it can be a custom callable annonymous function, or the name of the the method to call on this object
        if ($element->hasGetter()) {
            $getter = $element->getGetter();
            if (is_string($getter)) {
//method of this object
                return $this->$getter();
            } elseif (is_callable($getter)) {
// custom callable
                return $getter();
            } else {
                throw new \Exception('Getter is set but it is not usable : '.var_export($getter, true));
            }
        
        // else we use the property directly
        } else {
            $property = $element->getPropertyName();
            return $this->$property;
            
        }
        
        // TODO throw exception on no way to get element
    }
public function faceGetter ( $ needle ) { // look the type of $needle then dispatch if ( $ needle instanceof \ Face \ Core \ EntityFaceElement ) { /*  if is already a face element, dont beed anymore work */ $ element = $ needle ; } else if ( is_string ( $ needle ) ) { /*
             * if it is a string the string can be the name of the element or a chain of elements separated by a dot
             * e.g 
             *  - first form : "elementName"
             *  - secnd form : "elementName1.elementName2.elementName3"
             */ // TODO catch "this.elementName" case for dont instanciate a Navigator not needed for performances if ( false !== strpos ( $ needle , "." ) ) { return ( new Navigator ( $ needle ) ) -> chainGet ( $ this ) ; // "elementName1.elementName2.elementName3" case } else { $ element = $ this -> getEntityFace ( ) -> getElement ( $ needle ) ; // "elementName" case } } else { throw new BadParameterException ( "Variable of type '" . gettype ( $ needle ) . "' is not a valide type for faceGetter" ) ; } // if has a getter, it can be a custom callable annonymous function, or the name of the the method to call on this object if ( $ element -> hasGetter ( ) ) { $ getter = $ element -> getGetter ( ) ; if ( is_string ( $ getter ) ) { //method of this object return $ this -> $ getter ( ) ; } elseif ( is_callable ( $ getter ) ) { // custom callable return $ getter ( ) ; } else { throw new \ Exception ( 'Getter is set but it is not usable : ' . var_export ( $ getter , true ) ) ; } // else we use the property directly } else { $ property = $ element -> getPropertyName ( ) ; return $ this -> $ property ; } // TODO throw exception on no way to get element }
take the given element and use the right way for getting the value on this instance
@param \Face\Core\EntityFaceElement|string $element the element to get or the path to the element
@return mixed
take the given element and use the right way for getting the value on this instance