Version 1
[yaffs-website] / vendor / dflydev / placeholder-resolver / src / Dflydev / PlaceholderResolver / Cache / Cache.php
diff --git a/vendor/dflydev/placeholder-resolver/src/Dflydev/PlaceholderResolver/Cache/Cache.php b/vendor/dflydev/placeholder-resolver/src/Dflydev/PlaceholderResolver/Cache/Cache.php
new file mode 100644 (file)
index 0000000..8defa31
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+
+/*
+ * This file is a part of dflydev/placeholder-resolver.
+ *
+ * (c) Dragonfly Development Inc.
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Dflydev\PlaceholderResolver\Cache;
+
+class Cache implements CacheInterface
+{
+    private $cache = array();
+
+    /**
+     * {@inheritdoc}
+     */
+    public function exists($placeholder)
+    {
+        if (is_array($placeholder)) {
+            throw new \RuntimeException('Placeholder is an array');
+        }
+
+        return array_key_exists((string) $placeholder, $this->cache);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function get($placeholder)
+    {
+        if (is_array($placeholder)) {
+            throw new \RuntimeException('Placeholder is an array');
+        }
+
+        return array_key_exists((string) $placeholder, $this->cache)
+            ? $this->cache[(string) $placeholder]
+            : null;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function set($placeholder, $value = null)
+    {
+        if (is_array($placeholder)) {
+            throw new \RuntimeException('Placeholder is an array');
+        }
+        $this->cache[(string) $placeholder] = $value;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function flush()
+    {
+        $this->cache = array();
+    }
+}