phpffcms/ffcms-core

View on GitHub
src/Cache/MemoryObject.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace Ffcms\Core\Cache;

use Ffcms\Core\Traits\Singleton;

/**
 * Class MemoryObject. Simple singleton-type of magic __set and __get class to store any objects in memory (get and set)
 * @package Ffcms\Core\Cache
 */
class MemoryObject
{
    use Singleton;

    protected $data;

    /**
     * Set data to store
     * @param string $key
     * @param mixed $value
     */
    public function set($key, $value)
    {
        $this->data[$key] = $value;
    }

    /**
     * Get stored data
     * @param string $key
     * @return mixed
     */
    public function get($key)
    {
        return isset($this->data[$key]) ? $this->data[$key] : null;
    }
}