Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- someFactory(InstanceManager $im, $name, $isShared = false)
- {
- // calculate the service
- // ...
- // and do this:
- if ($isShared) {
- $im->set($name, $result);
- }
- // or:
- if ($isShared) {
- $this->service = $result;
- }
- // and on subsequent calls, return it early:
- if ($this->service) {
- return $this->service;
- }
- }
Add Comment
Please, Sign In to add comment