1: <?php
2: /**
3: * Pinoco: makes existing static web site dynamic transparently.
4: * Copyright 2010-2012, Hisateru Tanaka <tanakahisateru@gmail.com>
5: *
6: * Licensed under The MIT License
7: * Redistributions of files must retain the above copyright notice.
8: *
9: * PHP Version 5
10: *
11: * @author Hisateru Tanaka <tanakahisateru@gmail.com>
12: * @copyright Copyright 2010-2012, Hisateru Tanaka <tanakahisateru@gmail.com>
13: * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
14: * @package Pinoco
15: */
16:
17: /**
18: * Special Variable model as Nothing object.
19: *
20: * @package Pinoco
21: */
22: class Pinoco_NothingVars extends Pinoco_Vars
23: {
24: private static $_instance = null;
25:
26: /**
27: * Provides the unique Nothing instance.
28: *
29: * @return Pinoco_NothingVars
30: */
31: public static function instance()
32: {
33: if (self::$_instance === null) {
34: self::$_instance = new self;
35: }
36: return self::$_instance;
37: }
38:
39: /**
40: * Returns itself as globally unique NothingVars.
41: *
42: * @param string $name
43: * @param mixed $default
44: * @return Pinoco_NothingVars
45: */
46: public function get($name, $default=Pinoco_OptionalParam::UNSPECIFIED)
47: {
48: return $this;
49: }
50:
51: /**
52: * Nothing can respond to any names.
53: *
54: * @param string $name
55: * @return bool
56: */
57: public function has($name)
58: {
59: return true;
60: }
61:
62: /**
63: * Every values passed to Nothing would be lost.
64: *
65: * @param string $name
66: * @param mixed $value
67: * @return void
68: */
69: public function set($name, $value)
70: {
71: }
72:
73: /**
74: * Every values passed to Nothing would be lost.
75: *
76: * @param string $name
77: * @param callback $callable
78: * @return void
79: */
80: public function registerAsMethod($name, $callable)
81: {
82: //$this->set[$name] = new Pinoco_MethodProxy($callable, $this);
83: }
84:
85: /**
86: * Every values passed to Nothing would be lost.
87: *
88: * @param string $name
89: * @param callback $callable
90: * @param array $context
91: * @return void
92: */
93: public function registerAsDynamic($name, $callable, $context=array())
94: {
95: }
96:
97: /**
98: * Every values passed to Nothing would be lost.
99: *
100: * @param string $name
101: * @param callback $callable
102: * @param array $context
103: * @return void
104: */
105: public function registerAsLazy($name, $callable, $context=array())
106: {
107: }
108:
109: /**
110: * Every values passed to Nothing would be lost.
111: *
112: * @param mixed $src
113: * @param bool $filter
114: * @param null $default
115: * @param string $modifier
116: * @return void
117: */
118: public function import($src, $filter=false, $default=null, $modifier="%s")
119: {
120: }
121:
122: /**
123: * Nothing as Array is empty array.
124: *
125: * @param bool $filter
126: * @param null $default
127: * @param string $modifier
128: * @return array
129: */
130: public function toArray($filter=false, $default=null, $modifier="%s")
131: {
132: return array();
133: }
134:
135: /**
136: * Nothing as Array is empty array.
137: *
138: * @param int $depth
139: * @return array
140: */
141: public function toArrayRecurse($depth=null)
142: {
143: return array();
144: }
145:
146: /**
147: * Nothing as String is empty string.
148: *
149: * @return string
150: */
151: public function __toString()
152: {
153: return "";
154: }
155: }
156: