Jyxo\Spl\ObjectCache::set PHP Method

set() public static method

Saves an object into the default storage.
public static set ( string $key, object $value ) : object
$key string Object key
$value object Object
return object saved object
    public static function set($key, $value)
    {
        self::getInstance()->{$key} = $value;
        return $value;
    }

Usage Example

Beispiel #1
0
 /**
  * Static filtering.
  *
  * @param string $method Filter name
  * @param array $params Parameters; the first value gets filtered, the rest will be used as constructor parameters
  * @return mixed
  */
 public static function __callStatic(string $method, array $params)
 {
     $factory = \Jyxo\Spl\ObjectCache::get(\Jyxo\Input\Factory::class) ?: \Jyxo\Spl\ObjectCache::set(\Jyxo\Input\Factory::class, new Factory());
     $value = array_shift($params);
     $key = 'Jyxo\\Input\\Filter\\' . ucfirst($method) . ($params ? '/' . serialize($params) : '');
     $filter = \Jyxo\Spl\ObjectCache::get($key) ?: \Jyxo\Spl\ObjectCache::set($key, $factory->getFilterByName($method, $params));
     /* @var $filter \Jyxo\Input\FilterInterface */
     return $filter->filter($value);
 }
All Usage Examples Of Jyxo\Spl\ObjectCache::set