protected function objectToString($object)
    {
        $r = new \ReflectionClass(get_class($object));

        if ($r->hasMethod('__toString')) {
            return (string)$object;
        }

        foreach (['getName', 'getTitle'] as $getter) {
            if ($r->hasMethod($getter)) {
                try {
                    return $object->{$getter}();
                } catch (\Exception $e) {
                }
            }
        }

        return '';
    }
protected function objectToString($object)
    {
        $r = new \ReflectionClass(get_class($object));

        if ($r->hasMethod('__toString')) {
            return (string)$object;
        }

        foreach (['getName', 'getTitle'] as $getter) {
            if ($r->hasMethod($getter)) {
                try {
                    return $object->{$getter}();
                } catch (\Exception $e) {
                }
            }
        }

        return '';
    }
protected function objectToString ( $ object ) { $ r = new \ ReflectionClass ( get_class ( $ object ) ) ; if ( $ r -> hasMethod ( '__toString' ) ) { return ( string ) $ object ; } foreach ( [ 'getName' , 'getTitle' ] as $ getter ) { if ( $ r -> hasMethod ( $ getter ) ) { try { return $ object -> { $ getter } ( ) ; } catch ( \ Exception $ e ) { } } } return '' ; }
Returns the string representation of the given object.

@param $object
@return string
Returns the string representation of the given object .