PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 2.7.1
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v2.7.1
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
← All changes | assets/lib/Mustache/HelperCollection.php +170 -170 2.0.2 → 2.7.1 View file →
@@ -1,170 +1,170 @@
1 -<?php
2 -
3 -/*
4 - * This file is part of Mustache.php.
5 - *
6 - * (c) 2012 Justin Hileman
7 - *
8 - * For the full copyright and license information, please view the LICENSE
9 - * file that was distributed with this source code.
10 - */
11 -
12 -/**
13 - * A collection of helpers for a Mustache instance.
14 - */
15 -class Mustache_HelperCollection
16 -{
17 - private $helpers = array();
18 -
19 - /**
20 - * Helper Collection constructor.
21 - *
22 - * Optionally accepts an array (or Traversable) of `$name => $helper` pairs.
23 - *
24 - * @throws Mustache_Exception_InvalidArgumentException if the $helpers argument isn't an array or Traversable
25 - *
26 - * @param array|Traversable $helpers (default: null)
27 - */
28 - public function __construct($helpers = null)
29 - {
30 - if ($helpers !== null) {
31 - if (!is_array($helpers) && !$helpers instanceof Traversable) {
32 - throw new Mustache_Exception_InvalidArgumentException('HelperCollection constructor expects an array of helpers');
33 - }
34 -
35 - foreach ($helpers as $name => $helper) {
36 - $this->add($name, $helper);
37 - }
38 - }
39 - }
40 -
41 - /**
42 - * Magic mutator.
43 - *
44 - * @see Mustache_HelperCollection::add
45 - *
46 - * @param string $name
47 - * @param mixed $helper
48 - */
49 - public function __set($name, $helper)
50 - {
51 - $this->add($name, $helper);
52 - }
53 -
54 - /**
55 - * Add a helper to this collection.
56 - *
57 - * @param string $name
58 - * @param mixed $helper
59 - */
60 - public function add($name, $helper)
61 - {
62 - $this->helpers[$name] = $helper;
63 - }
64 -
65 - /**
66 - * Magic accessor.
67 - *
68 - * @see Mustache_HelperCollection::get
69 - *
70 - * @param string $name
71 - *
72 - * @return mixed Helper
73 - */
74 - public function __get($name)
75 - {
76 - return $this->get($name);
77 - }
78 -
79 - /**
80 - * Get a helper by name.
81 - *
82 - * @throws Mustache_Exception_UnknownHelperException If helper does not exist.
83 - *
84 - * @param string $name
85 - *
86 - * @return mixed Helper
87 - */
88 - public function get($name)
89 - {
90 - if (!$this->has($name)) {
91 - throw new Mustache_Exception_UnknownHelperException($name);
92 - }
93 -
94 - return $this->helpers[$name];
95 - }
96 -
97 - /**
98 - * Magic isset().
99 - *
100 - * @see Mustache_HelperCollection::has
101 - *
102 - * @param string $name
103 - *
104 - * @return boolean True if helper is present
105 - */
106 - public function __isset($name)
107 - {
108 - return $this->has($name);
109 - }
110 -
111 - /**
112 - * Check whether a given helper is present in the collection.
113 - *
114 - * @param string $name
115 - *
116 - * @return boolean True if helper is present
117 - */
118 - public function has($name)
119 - {
120 - return array_key_exists($name, $this->helpers);
121 - }
122 -
123 - /**
124 - * Magic unset().
125 - *
126 - * @see Mustache_HelperCollection::remove
127 - *
128 - * @param string $name
129 - */
130 - public function __unset($name)
131 - {
132 - $this->remove($name);
133 - }
134 -
135 - /**
136 - * Check whether a given helper is present in the collection.
137 - *
138 - * @throws Mustache_Exception_UnknownHelperException if the requested helper is not present.
139 - *
140 - * @param string $name
141 - */
142 - public function remove($name)
143 - {
144 - if (!$this->has($name)) {
145 - throw new Mustache_Exception_UnknownHelperException($name);
146 - }
147 -
148 - unset($this->helpers[$name]);
149 - }
150 -
151 - /**
152 - * Clear the helper collection.
153 - *
154 - * Removes all helpers from this collection
155 - */
156 - public function clear()
157 - {
158 - $this->helpers = array();
159 - }
160 -
161 - /**
162 - * Check whether the helper collection is empty.
163 - *
164 - * @return boolean True if the collection is empty
165 - */
166 - public function isEmpty()
167 - {
168 - return empty($this->helpers);
169 - }
170 -}
1 +<?php
2 +
3 +/*
4 + * This file is part of Mustache.php.
5 + *
6 + * (c) 2012 Justin Hileman
7 + *
8 + * For the full copyright and license information, please view the LICENSE
9 + * file that was distributed with this source code.
10 + */
11 +
12 +/**
13 + * A collection of helpers for a Mustache instance.
14 + */
15 +class Mustache_HelperCollection
16 +{
17 + private $helpers = array();
18 +
19 + /**
20 + * Helper Collection constructor.
21 + *
22 + * Optionally accepts an array (or Traversable) of `$name => $helper` pairs.
23 + *
24 + * @throws Mustache_Exception_InvalidArgumentException if the $helpers argument isn't an array or Traversable
25 + *
26 + * @param array|Traversable $helpers (default: null)
27 + */
28 + public function __construct($helpers = null)
29 + {
30 + if ($helpers !== null) {
31 + if (!is_array($helpers) && !$helpers instanceof Traversable) {
32 + throw new Mustache_Exception_InvalidArgumentException('HelperCollection constructor expects an array of helpers');
33 + }
34 +
35 + foreach ($helpers as $name => $helper) {
36 + $this->add($name, $helper);
37 + }
38 + }
39 + }
40 +
41 + /**
42 + * Magic mutator.
43 + *
44 + * @see Mustache_HelperCollection::add
45 + *
46 + * @param string $name
47 + * @param mixed $helper
48 + */
49 + public function __set($name, $helper)
50 + {
51 + $this->add($name, $helper);
52 + }
53 +
54 + /**
55 + * Add a helper to this collection.
56 + *
57 + * @param string $name
58 + * @param mixed $helper
59 + */
60 + public function add($name, $helper)
61 + {
62 + $this->helpers[$name] = $helper;
63 + }
64 +
65 + /**
66 + * Magic accessor.
67 + *
68 + * @see Mustache_HelperCollection::get
69 + *
70 + * @param string $name
71 + *
72 + * @return mixed Helper
73 + */
74 + public function __get($name)
75 + {
76 + return $this->get($name);
77 + }
78 +
79 + /**
80 + * Get a helper by name.
81 + *
82 + * @throws Mustache_Exception_UnknownHelperException If helper does not exist.
83 + *
84 + * @param string $name
85 + *
86 + * @return mixed Helper
87 + */
88 + public function get($name)
89 + {
90 + if (!$this->has($name)) {
91 + throw new Mustache_Exception_UnknownHelperException($name);
92 + }
93 +
94 + return $this->helpers[$name];
95 + }
96 +
97 + /**
98 + * Magic isset().
99 + *
100 + * @see Mustache_HelperCollection::has
101 + *
102 + * @param string $name
103 + *
104 + * @return boolean True if helper is present
105 + */
106 + public function __isset($name)
107 + {
108 + return $this->has($name);
109 + }
110 +
111 + /**
112 + * Check whether a given helper is present in the collection.
113 + *
114 + * @param string $name
115 + *
116 + * @return boolean True if helper is present
117 + */
118 + public function has($name)
119 + {
120 + return array_key_exists($name, $this->helpers);
121 + }
122 +
123 + /**
124 + * Magic unset().
125 + *
126 + * @see Mustache_HelperCollection::remove
127 + *
128 + * @param string $name
129 + */
130 + public function __unset($name)
131 + {
132 + $this->remove($name);
133 + }
134 +
135 + /**
136 + * Check whether a given helper is present in the collection.
137 + *
138 + * @throws Mustache_Exception_UnknownHelperException if the requested helper is not present.
139 + *
140 + * @param string $name
141 + */
142 + public function remove($name)
143 + {
144 + if (!$this->has($name)) {
145 + throw new Mustache_Exception_UnknownHelperException($name);
146 + }
147 +
148 + unset($this->helpers[$name]);
149 + }
150 +
151 + /**
152 + * Clear the helper collection.
153 + *
154 + * Removes all helpers from this collection
155 + */
156 + public function clear()
157 + {
158 + $this->helpers = array();
159 + }
160 +
161 + /**
162 + * Check whether the helper collection is empty.
163 + *
164 + * @return boolean True if the collection is empty
165 + */
166 + public function isEmpty()
167 + {
168 + return empty($this->helpers);
169 + }
170 +}