@@ -22,110 +22,110 @@ |
||
22 | 22 | class CachingLoader extends LoaderDecorator |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * @var CollectionInterface $cache |
|
27 | - */ |
|
28 | - protected $cache; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var string $identifier |
|
32 | - */ |
|
33 | - protected $identifier; |
|
34 | - |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * CachingLoader constructor. |
|
39 | - * |
|
40 | - * @param LoaderInterface $loader |
|
41 | - * @param CollectionInterface $cache |
|
42 | - * @param string $identifier |
|
43 | - * @throws InvalidDataTypeException |
|
44 | - */ |
|
45 | - public function __construct(LoaderInterface $loader, CollectionInterface $cache, $identifier = '') |
|
46 | - { |
|
47 | - parent::__construct($loader); |
|
48 | - $this->cache = $cache; |
|
49 | - $this->identifier = $this->setIdentifier($identifier); |
|
50 | - if ($this->identifier !== '') { |
|
51 | - // to only clear this cache, and assuming an identifier has been set, simply do the following: |
|
52 | - // do_action('AHEE__EventEspresso\core\services\loaders\CachingLoader__resetCache__IDENTIFIER'); |
|
53 | - // where "IDENTIFIER" = the string that was set during construction |
|
54 | - add_action( |
|
55 | - "AHEE__EventEspresso\\core\\services\\loaders\\CachingLoader__resetCache__{$identifier}", |
|
56 | - array($this, 'resetCache') |
|
57 | - ); |
|
58 | - } |
|
59 | - // to clear ALL caches, simply do the following: |
|
60 | - // do_action('AHEE__EventEspresso\core\services\loaders\CachingLoader__resetCache'); |
|
61 | - add_action( |
|
62 | - 'AHEE__EventEspresso\core\services\loaders\CachingLoader__resetCache', |
|
63 | - array($this, 'resetCache') |
|
64 | - ); |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - public function identifier() |
|
73 | - { |
|
74 | - return $this->identifier; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * @param string $identifier |
|
81 | - * @throws InvalidDataTypeException |
|
82 | - */ |
|
83 | - public function setIdentifier($identifier) |
|
84 | - { |
|
85 | - if ( ! is_string($identifier)) { |
|
86 | - throw new InvalidDataTypeException('$identifier', $identifier, 'string'); |
|
87 | - } |
|
88 | - $this->identifier = $identifier; |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * @param string $fqcn |
|
95 | - * @param array $arguments |
|
96 | - * @return mixed |
|
97 | - * @throws InvalidEntityException |
|
98 | - * @throws ServiceNotFoundException |
|
99 | - */ |
|
100 | - public function load($fqcn, $arguments = array()) |
|
101 | - { |
|
102 | - $fqcn = ltrim($fqcn, '\\'); |
|
103 | - // caching can be turned off via the following code: |
|
104 | - // add_filter('FHEE__EventEspresso\core\services\loaders\CachingLoader__load__bypass_cache', '__return_true'); |
|
105 | - if( |
|
106 | - apply_filters( |
|
107 | - 'FHEE__EventEspresso\core\services\loaders\CachingLoader__load__bypass_cache', |
|
108 | - false, |
|
109 | - $this |
|
110 | - ) |
|
111 | - ){ |
|
112 | - return $this->loader->load($fqcn, $arguments); |
|
113 | - } |
|
114 | - $identifier = md5($fqcn . serialize($arguments)); |
|
115 | - if($this->cache->has($identifier)){ |
|
116 | - return $this->cache->get($identifier); |
|
117 | - } |
|
118 | - $object = $this->loader->load($fqcn, $arguments); |
|
119 | - $this->cache->add($object, $identifier); |
|
120 | - return $object; |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - |
|
125 | - public function resetCache() |
|
126 | - { |
|
127 | - $this->cache->reset(); |
|
128 | - } |
|
25 | + /** |
|
26 | + * @var CollectionInterface $cache |
|
27 | + */ |
|
28 | + protected $cache; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var string $identifier |
|
32 | + */ |
|
33 | + protected $identifier; |
|
34 | + |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * CachingLoader constructor. |
|
39 | + * |
|
40 | + * @param LoaderInterface $loader |
|
41 | + * @param CollectionInterface $cache |
|
42 | + * @param string $identifier |
|
43 | + * @throws InvalidDataTypeException |
|
44 | + */ |
|
45 | + public function __construct(LoaderInterface $loader, CollectionInterface $cache, $identifier = '') |
|
46 | + { |
|
47 | + parent::__construct($loader); |
|
48 | + $this->cache = $cache; |
|
49 | + $this->identifier = $this->setIdentifier($identifier); |
|
50 | + if ($this->identifier !== '') { |
|
51 | + // to only clear this cache, and assuming an identifier has been set, simply do the following: |
|
52 | + // do_action('AHEE__EventEspresso\core\services\loaders\CachingLoader__resetCache__IDENTIFIER'); |
|
53 | + // where "IDENTIFIER" = the string that was set during construction |
|
54 | + add_action( |
|
55 | + "AHEE__EventEspresso\\core\\services\\loaders\\CachingLoader__resetCache__{$identifier}", |
|
56 | + array($this, 'resetCache') |
|
57 | + ); |
|
58 | + } |
|
59 | + // to clear ALL caches, simply do the following: |
|
60 | + // do_action('AHEE__EventEspresso\core\services\loaders\CachingLoader__resetCache'); |
|
61 | + add_action( |
|
62 | + 'AHEE__EventEspresso\core\services\loaders\CachingLoader__resetCache', |
|
63 | + array($this, 'resetCache') |
|
64 | + ); |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + public function identifier() |
|
73 | + { |
|
74 | + return $this->identifier; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * @param string $identifier |
|
81 | + * @throws InvalidDataTypeException |
|
82 | + */ |
|
83 | + public function setIdentifier($identifier) |
|
84 | + { |
|
85 | + if ( ! is_string($identifier)) { |
|
86 | + throw new InvalidDataTypeException('$identifier', $identifier, 'string'); |
|
87 | + } |
|
88 | + $this->identifier = $identifier; |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * @param string $fqcn |
|
95 | + * @param array $arguments |
|
96 | + * @return mixed |
|
97 | + * @throws InvalidEntityException |
|
98 | + * @throws ServiceNotFoundException |
|
99 | + */ |
|
100 | + public function load($fqcn, $arguments = array()) |
|
101 | + { |
|
102 | + $fqcn = ltrim($fqcn, '\\'); |
|
103 | + // caching can be turned off via the following code: |
|
104 | + // add_filter('FHEE__EventEspresso\core\services\loaders\CachingLoader__load__bypass_cache', '__return_true'); |
|
105 | + if( |
|
106 | + apply_filters( |
|
107 | + 'FHEE__EventEspresso\core\services\loaders\CachingLoader__load__bypass_cache', |
|
108 | + false, |
|
109 | + $this |
|
110 | + ) |
|
111 | + ){ |
|
112 | + return $this->loader->load($fqcn, $arguments); |
|
113 | + } |
|
114 | + $identifier = md5($fqcn . serialize($arguments)); |
|
115 | + if($this->cache->has($identifier)){ |
|
116 | + return $this->cache->get($identifier); |
|
117 | + } |
|
118 | + $object = $this->loader->load($fqcn, $arguments); |
|
119 | + $this->cache->add($object, $identifier); |
|
120 | + return $object; |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + |
|
125 | + public function resetCache() |
|
126 | + { |
|
127 | + $this->cache->reset(); |
|
128 | + } |
|
129 | 129 | |
130 | 130 | |
131 | 131 | } |
@@ -102,17 +102,17 @@ |
||
102 | 102 | $fqcn = ltrim($fqcn, '\\'); |
103 | 103 | // caching can be turned off via the following code: |
104 | 104 | // add_filter('FHEE__EventEspresso\core\services\loaders\CachingLoader__load__bypass_cache', '__return_true'); |
105 | - if( |
|
105 | + if ( |
|
106 | 106 | apply_filters( |
107 | 107 | 'FHEE__EventEspresso\core\services\loaders\CachingLoader__load__bypass_cache', |
108 | 108 | false, |
109 | 109 | $this |
110 | 110 | ) |
111 | - ){ |
|
111 | + ) { |
|
112 | 112 | return $this->loader->load($fqcn, $arguments); |
113 | 113 | } |
114 | - $identifier = md5($fqcn . serialize($arguments)); |
|
115 | - if($this->cache->has($identifier)){ |
|
114 | + $identifier = md5($fqcn.serialize($arguments)); |
|
115 | + if ($this->cache->has($identifier)) { |
|
116 | 116 | return $this->cache->get($identifier); |
117 | 117 | } |
118 | 118 | $object = $this->loader->load($fqcn, $arguments); |
@@ -24,79 +24,79 @@ |
||
24 | 24 | { |
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * @var LoaderInterface $new_loader |
|
29 | - */ |
|
30 | - private $new_loader; |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * @var LoaderInterface $shared_loader |
|
35 | - */ |
|
36 | - private $shared_loader; |
|
37 | - |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * Loader constructor. |
|
42 | - * |
|
43 | - * @param LoaderInterface|null $new_loader |
|
44 | - * @param LoaderInterface|null $shared_loader |
|
45 | - * @throws InvalidInterfaceException |
|
46 | - * @throws InvalidArgumentException |
|
47 | - * @throws InvalidDataTypeException |
|
48 | - */ |
|
49 | - public function __construct(LoaderInterface $new_loader = null, LoaderInterface $shared_loader = null) |
|
50 | - { |
|
51 | - // if not already generated, create a standard loader |
|
52 | - if (! $new_loader instanceof LoaderInterface) { |
|
53 | - $new_loader = new CoreLoader(EE_Registry::instance()); |
|
54 | - } |
|
55 | - $this->new_loader = $new_loader; |
|
56 | - // if not already generated, create a caching loader |
|
57 | - if (! $shared_loader instanceof LoaderInterface) { |
|
58 | - $shared_loader = new CachingLoader( |
|
59 | - new CoreLoader(EE_Registry::instance()), |
|
60 | - new LooseCollection('') |
|
61 | - ); |
|
62 | - } |
|
63 | - $this->shared_loader = $shared_loader; |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * @return LoaderInterface |
|
70 | - */ |
|
71 | - public function getNewLoader() |
|
72 | - { |
|
73 | - return $this->new_loader; |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @return LoaderInterface |
|
80 | - */ |
|
81 | - public function getSharedLoader() |
|
82 | - { |
|
83 | - return $this->shared_loader; |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * @param string $fqcn |
|
90 | - * @param array $arguments |
|
91 | - * @param bool $shared |
|
92 | - * @return mixed |
|
93 | - */ |
|
94 | - public function load($fqcn, $arguments = array(), $shared = true) |
|
95 | - { |
|
96 | - return $shared |
|
97 | - ? $this->getSharedLoader()->load($fqcn, $arguments) |
|
98 | - : $this->getNewLoader()->load($fqcn, $arguments); |
|
99 | - } |
|
27 | + /** |
|
28 | + * @var LoaderInterface $new_loader |
|
29 | + */ |
|
30 | + private $new_loader; |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * @var LoaderInterface $shared_loader |
|
35 | + */ |
|
36 | + private $shared_loader; |
|
37 | + |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * Loader constructor. |
|
42 | + * |
|
43 | + * @param LoaderInterface|null $new_loader |
|
44 | + * @param LoaderInterface|null $shared_loader |
|
45 | + * @throws InvalidInterfaceException |
|
46 | + * @throws InvalidArgumentException |
|
47 | + * @throws InvalidDataTypeException |
|
48 | + */ |
|
49 | + public function __construct(LoaderInterface $new_loader = null, LoaderInterface $shared_loader = null) |
|
50 | + { |
|
51 | + // if not already generated, create a standard loader |
|
52 | + if (! $new_loader instanceof LoaderInterface) { |
|
53 | + $new_loader = new CoreLoader(EE_Registry::instance()); |
|
54 | + } |
|
55 | + $this->new_loader = $new_loader; |
|
56 | + // if not already generated, create a caching loader |
|
57 | + if (! $shared_loader instanceof LoaderInterface) { |
|
58 | + $shared_loader = new CachingLoader( |
|
59 | + new CoreLoader(EE_Registry::instance()), |
|
60 | + new LooseCollection('') |
|
61 | + ); |
|
62 | + } |
|
63 | + $this->shared_loader = $shared_loader; |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * @return LoaderInterface |
|
70 | + */ |
|
71 | + public function getNewLoader() |
|
72 | + { |
|
73 | + return $this->new_loader; |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @return LoaderInterface |
|
80 | + */ |
|
81 | + public function getSharedLoader() |
|
82 | + { |
|
83 | + return $this->shared_loader; |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * @param string $fqcn |
|
90 | + * @param array $arguments |
|
91 | + * @param bool $shared |
|
92 | + * @return mixed |
|
93 | + */ |
|
94 | + public function load($fqcn, $arguments = array(), $shared = true) |
|
95 | + { |
|
96 | + return $shared |
|
97 | + ? $this->getSharedLoader()->load($fqcn, $arguments) |
|
98 | + : $this->getNewLoader()->load($fqcn, $arguments); |
|
99 | + } |
|
100 | 100 | |
101 | 101 | } |
102 | 102 | // End of file Loader.php |
@@ -49,12 +49,12 @@ |
||
49 | 49 | public function __construct(LoaderInterface $new_loader = null, LoaderInterface $shared_loader = null) |
50 | 50 | { |
51 | 51 | // if not already generated, create a standard loader |
52 | - if (! $new_loader instanceof LoaderInterface) { |
|
52 | + if ( ! $new_loader instanceof LoaderInterface) { |
|
53 | 53 | $new_loader = new CoreLoader(EE_Registry::instance()); |
54 | 54 | } |
55 | 55 | $this->new_loader = $new_loader; |
56 | 56 | // if not already generated, create a caching loader |
57 | - if (! $shared_loader instanceof LoaderInterface) { |
|
57 | + if ( ! $shared_loader instanceof LoaderInterface) { |
|
58 | 58 | $shared_loader = new CachingLoader( |
59 | 59 | new CoreLoader(EE_Registry::instance()), |
60 | 60 | new LooseCollection('') |
@@ -23,46 +23,46 @@ |
||
23 | 23 | class CoreLoader implements LoaderInterface |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * @var EE_Registry|CoffeeShop $generator |
|
28 | - */ |
|
29 | - private $generator; |
|
26 | + /** |
|
27 | + * @var EE_Registry|CoffeeShop $generator |
|
28 | + */ |
|
29 | + private $generator; |
|
30 | 30 | |
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * CoreLoader constructor. |
|
35 | - * |
|
36 | - * @param EE_Registry|CoffeeShop $generator |
|
37 | - * @throws InvalidArgumentException |
|
38 | - */ |
|
39 | - public function __construct($generator) |
|
40 | - { |
|
41 | - if(!($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) { |
|
42 | - throw new InvalidArgumentException( |
|
43 | - esc_html__( |
|
44 | - 'The CoreLoader class must receive an instance of EE_Registry or the CoffeeShop DI container.', |
|
45 | - 'event_espresso' |
|
46 | - ) |
|
47 | - ); |
|
48 | - } |
|
49 | - $this->generator = $generator; |
|
50 | - } |
|
33 | + /** |
|
34 | + * CoreLoader constructor. |
|
35 | + * |
|
36 | + * @param EE_Registry|CoffeeShop $generator |
|
37 | + * @throws InvalidArgumentException |
|
38 | + */ |
|
39 | + public function __construct($generator) |
|
40 | + { |
|
41 | + if(!($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) { |
|
42 | + throw new InvalidArgumentException( |
|
43 | + esc_html__( |
|
44 | + 'The CoreLoader class must receive an instance of EE_Registry or the CoffeeShop DI container.', |
|
45 | + 'event_espresso' |
|
46 | + ) |
|
47 | + ); |
|
48 | + } |
|
49 | + $this->generator = $generator; |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * @param string $fqcn |
|
56 | - * @param array $arguments |
|
57 | - * @return mixed |
|
58 | - * @throws ServiceNotFoundException |
|
59 | - */ |
|
60 | - public function load($fqcn, $arguments = array()) |
|
61 | - { |
|
62 | - return $this->generator instanceof EE_Registry |
|
63 | - ? $this->generator->create($fqcn, $arguments) |
|
64 | - : $this->generator->brew($fqcn, $arguments); |
|
65 | - } |
|
54 | + /** |
|
55 | + * @param string $fqcn |
|
56 | + * @param array $arguments |
|
57 | + * @return mixed |
|
58 | + * @throws ServiceNotFoundException |
|
59 | + */ |
|
60 | + public function load($fqcn, $arguments = array()) |
|
61 | + { |
|
62 | + return $this->generator instanceof EE_Registry |
|
63 | + ? $this->generator->create($fqcn, $arguments) |
|
64 | + : $this->generator->brew($fqcn, $arguments); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | } |
68 | 68 | // End of file CoreLoader.php |
@@ -38,7 +38,7 @@ |
||
38 | 38 | */ |
39 | 39 | public function __construct($generator) |
40 | 40 | { |
41 | - if(!($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) { |
|
41 | + if ( ! ($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) { |
|
42 | 42 | throw new InvalidArgumentException( |
43 | 43 | esc_html__( |
44 | 44 | 'The CoreLoader class must receive an instance of EE_Registry or the CoffeeShop DI container.', |
@@ -19,22 +19,22 @@ |
||
19 | 19 | { |
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * @var LoaderInterface $loader |
|
24 | - */ |
|
25 | - protected $loader; |
|
26 | - |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * LoaderDecorator constructor. |
|
31 | - * |
|
32 | - * @param LoaderInterface $loader |
|
33 | - */ |
|
34 | - public function __construct(LoaderInterface $loader) |
|
35 | - { |
|
36 | - $this->loader = $loader; |
|
37 | - } |
|
22 | + /** |
|
23 | + * @var LoaderInterface $loader |
|
24 | + */ |
|
25 | + protected $loader; |
|
26 | + |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * LoaderDecorator constructor. |
|
31 | + * |
|
32 | + * @param LoaderInterface $loader |
|
33 | + */ |
|
34 | + public function __construct(LoaderInterface $loader) |
|
35 | + { |
|
36 | + $this->loader = $loader; |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | 40 |
@@ -9,12 +9,12 @@ |
||
9 | 9 | interface LoaderInterface |
10 | 10 | { |
11 | 11 | |
12 | - /** |
|
13 | - * @param string $fqcn |
|
14 | - * @param array $arguments |
|
15 | - * @return mixed |
|
16 | - */ |
|
17 | - public function load($fqcn, $arguments = array()); |
|
12 | + /** |
|
13 | + * @param string $fqcn |
|
14 | + * @param array $arguments |
|
15 | + * @return mixed |
|
16 | + */ |
|
17 | + public function load($fqcn, $arguments = array()); |
|
18 | 18 | |
19 | 19 | } |
20 | 20 | // End of file LoaderInterface.php |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | public function previous(); |
114 | 114 | |
115 | 115 | /** |
116 | - * Returns the index of a given object, or false if not found |
|
117 | - * |
|
118 | - * @see http://stackoverflow.com/a/8736013 |
|
119 | - * @param $object |
|
120 | - * @return boolean|int|string |
|
121 | - */ |
|
116 | + * Returns the index of a given object, or false if not found |
|
117 | + * |
|
118 | + * @see http://stackoverflow.com/a/8736013 |
|
119 | + * @param $object |
|
120 | + * @return boolean|int|string |
|
121 | + */ |
|
122 | 122 | public function indexOf( $object ); |
123 | 123 | |
124 | 124 | |
@@ -160,10 +160,10 @@ discard block |
||
160 | 160 | |
161 | 161 | |
162 | 162 | |
163 | - /** |
|
164 | - * Removes ALL objects from the Collection |
|
165 | - */ |
|
166 | - public function reset(); |
|
163 | + /** |
|
164 | + * Removes ALL objects from the Collection |
|
165 | + */ |
|
166 | + public function reset(); |
|
167 | 167 | |
168 | 168 | } |
169 | 169 | // End of file CollectionInterface.php |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\services\collections; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @param mixed $identifier |
28 | 28 | * @return bool |
29 | 29 | */ |
30 | - public function add( $object, $identifier = null ); |
|
30 | + public function add($object, $identifier = null); |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * setIdentifier |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param mixed $identifier |
40 | 40 | * @return bool |
41 | 41 | */ |
42 | - public function setIdentifier( $object, $identifier = null ); |
|
42 | + public function setIdentifier($object, $identifier = null); |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * get |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param mixed $identifier |
51 | 51 | * @return mixed |
52 | 52 | */ |
53 | - public function get( $identifier ); |
|
53 | + public function get($identifier); |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * has |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param mixed $identifier |
63 | 63 | * @return bool |
64 | 64 | */ |
65 | - public function has( $identifier ); |
|
65 | + public function has($identifier); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * hasObject |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param $object |
73 | 73 | * @return bool |
74 | 74 | */ |
75 | - public function hasObject( $object ); |
|
75 | + public function hasObject($object); |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * remove |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param $object |
83 | 83 | * @return bool |
84 | 84 | */ |
85 | - public function remove( $object ); |
|
85 | + public function remove($object); |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * setCurrent |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @param mixed $identifier |
93 | 93 | * @return boolean |
94 | 94 | */ |
95 | - public function setCurrent( $identifier ) ; |
|
95 | + public function setCurrent($identifier); |
|
96 | 96 | |
97 | 97 | /** |
98 | 98 | * setCurrentUsingObject |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param $object |
103 | 103 | * @return boolean |
104 | 104 | */ |
105 | - public function setCurrentUsingObject( $object ); |
|
105 | + public function setCurrentUsingObject($object); |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Returns the object occupying the index before the current object, |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param $object |
120 | 120 | * @return boolean|int|string |
121 | 121 | */ |
122 | - public function indexOf( $object ); |
|
122 | + public function indexOf($object); |
|
123 | 123 | |
124 | 124 | |
125 | 125 | /** |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @param $index |
130 | 130 | * @return mixed |
131 | 131 | */ |
132 | - public function objectAtIndex( $index ); |
|
132 | + public function objectAtIndex($index); |
|
133 | 133 | |
134 | 134 | /** |
135 | 135 | * Returns the sequence of objects as specified by the offset and length |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @param int $length |
140 | 140 | * @return array |
141 | 141 | */ |
142 | - public function slice( $offset, $length ); |
|
142 | + public function slice($offset, $length); |
|
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Inserts an object (or an array of objects) at a certain point |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param mixed $objects A single object or an array of objects |
149 | 149 | * @param integer $index |
150 | 150 | */ |
151 | - public function insertAt( $objects, $index ); |
|
151 | + public function insertAt($objects, $index); |
|
152 | 152 | |
153 | 153 | /** |
154 | 154 | * Removes the object at the given index |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * @see http://stackoverflow.com/a/8736013 |
157 | 157 | * @param integer $index |
158 | 158 | */ |
159 | - public function removeAt( $index ) ; |
|
159 | + public function removeAt($index); |
|
160 | 160 | |
161 | 161 | |
162 | 162 |
@@ -83,7 +83,6 @@ discard block |
||
83 | 83 | |
84 | 84 | /** |
85 | 85 | * setIdentifier |
86 | - |
|
87 | 86 | * Sets the data associated with an object in the Collection |
88 | 87 | * if no $identifier is supplied, then the spl_object_hash() is used |
89 | 88 | * |
@@ -352,18 +351,18 @@ discard block |
||
352 | 351 | |
353 | 352 | |
354 | 353 | |
355 | - /** |
|
356 | - * Removes ALL objects from the Collection |
|
357 | - */ |
|
358 | - public function reset() |
|
359 | - { |
|
360 | - $this->rewind(); |
|
361 | - while ($this->valid()) { |
|
362 | - $object = $this->current(); |
|
363 | - $this->next(); |
|
364 | - $this->detach($object); |
|
365 | - } |
|
366 | - } |
|
354 | + /** |
|
355 | + * Removes ALL objects from the Collection |
|
356 | + */ |
|
357 | + public function reset() |
|
358 | + { |
|
359 | + $this->rewind(); |
|
360 | + while ($this->valid()) { |
|
361 | + $object = $this->current(); |
|
362 | + $this->next(); |
|
363 | + $this->detach($object); |
|
364 | + } |
|
365 | + } |
|
367 | 366 | |
368 | 367 | |
369 | 368 |