Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Ensure a value or object will remain globally unique
- * @param string $key The value or object name
- * @param Closure The closure that defines the object
- * @return mixed
- */
- public function singleton($key, $value)
- {
- $this->set($key, function ($c) use ($value) {
- static $object;
- if (null === $object) {
- $object = $value($c);
- }
- return $object;
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment