DataSift\Storyplayer\PlayerLib\Story_Checkpoint::getString PHP Метод

getString() публичный Метод

return the named property as a string, or return the default if the property isn't a string
public getString ( string $propName, string $default = '' ) : string
$propName string name of property to retrieve
$default string default value to return if property not set
Результат string
    public function getString($propName, $default = '')
    {
        // does this property exist at all?
        if (!isset($this->{$propName})) {
            // no, so return the default
            return $default;
        }
        // is this property something that can be auto-converted to a
        // string reliably?
        if (is_string($this->{$propName}) || is_int($this->{$propName}) || is_double($this->{$propName})) {
            // yes
            return (string) $this->{$propName};
        }
        // starting to clutch at straws now
        // a boolean, perhaps?
        if (is_bool($this->{$propName})) {
            if ($this->{$propName}) {
                return 'TRUE';
            }
            return 'FALSE';
        }
        // is it an object that can convert itself to a string?
        if (is_object($this->{$propName})) {
            $refObj = new ReflectionObject($this->{$propName});
            if ($refObj->hasMethod('__toString')) {
                return (string) $this->{$propName};
            }
            // sadly, the object cannot convert itself to a string
            return $default;
        }
        // add any other conversions in here
        // okay, we give up
        return $default;
    }