| 1 | <?php |
||
| 17 | class SharedStorage implements SharedStorageInterface |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @var array |
||
| 21 | */ |
||
| 22 | private $clipboard = []; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var string|null |
||
| 26 | */ |
||
| 27 | private $latestKey = null; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * {@inheritdoc} |
||
| 31 | */ |
||
| 32 | public function get($key) |
||
| 33 | { |
||
| 34 | if (!isset($this->clipboard[$key])) { |
||
| 35 | throw new \InvalidArgumentException(sprintf('There is no current resource for "%s"!', $key)); |
||
| 36 | } |
||
| 37 | |||
| 38 | return $this->clipboard[$key]; |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * {@inheritdoc} |
||
| 43 | */ |
||
| 44 | public function set($key, $resource) |
||
| 45 | { |
||
| 46 | $this->clipboard[$key] = $resource; |
||
| 47 | $this->latestKey = $key; |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * {@inheritdoc} |
||
| 52 | */ |
||
| 53 | public function getLatestResource() |
||
| 61 | |||
| 62 | /** |
||
| 63 | * {@inheritdoc} |
||
| 64 | */ |
||
| 65 | public function setClipboard(array $clipboard) |
||
| 69 | } |
||
| 70 |