Guest User

Untitled

a guest
Jul 16th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. <?php
  2. class Spawned {
  3. public $variable = 'test';
  4. }
  5.  
  6. class Factory {
  7. public function create() {
  8. return new Spawned();
  9. }
  10.  
  11. public function alter($object, $variable) {
  12. $object->variable = $variable;
  13. }
  14. }
  15.  
  16. $factory = new Factory();
  17.  
  18. $testobject = $factory->create();
  19. $factory->alter($testobject, 'bier');
  20.  
  21. // Expected output: bier
  22. echo $testobject->variable;
  23. ?>
Add Comment
Please, Sign In to add comment