Guest User

Untitled

a guest
Jul 16th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.29 KB | None | 0 0
  1. <?php
  2.  
  3. someFactory(InstanceManager $im, $service)
  4. {
  5.     // calculate the service
  6.     // ...
  7.     // and do this:
  8.     $im->set($service, $result);
  9.  
  10.     // or:
  11.     $this->service = $result;
  12.  
  13.     // and on subsequent calls, return it early:
  14.     if ($this->service) {
  15.         return $this->service;
  16.     }
  17. }
Add Comment
Please, Sign In to add comment