MathPHP\SetTheory\Set::getKey PHP Method

getKey() protected method

Based on the type of member to be added, the key differs: - Number: value as is - String: value as is - Set: String representation of set. Example: {1, 2} - Array: Array(array_serialization) - Object: Class\Name(object_hash) - Resource: Resource(Resource id #) - Null: ''
protected getKey ( mixed $x ) : string
$x mixed
return string
    protected function getKey($x)
    {
        if (is_int($x) || is_float($x) || is_string($x) || $x instanceof Set) {
            return "{$x}";
        } elseif (is_object($x)) {
            return get_class($x) . '(' . spl_object_hash($x) . ')';
        } elseif (is_array($x)) {
            return 'Array(' . serialize($x) . ')';
        } elseif (is_resource($x)) {
            return 'Resource(' . strval($x) . ')';
        }
        return null;
    }