Last active
August 29, 2015 14:08
-
-
Save e0ipso/77ef4c4dba8c3659485a to your computer and use it in GitHub Desktop.
Accessors and mutators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyController extends ControllerBase implements ControllerInterface { | |
/** | |
* @var MyClass1 | |
* Object of Class 1 | |
*/ | |
protected $obj1; | |
/** | |
* @var MyClass2 | |
* Object of Class 2 | |
*/ | |
protected $obj2; | |
/** | |
* @var MyClass3 | |
* Object of Class 3 | |
*/ | |
protected $obj3; | |
/** | |
* Default constructor. | |
* | |
* @param MyClass1 object1 | |
* @param MyClass2 object2 | |
* @param MyClass3 object3 | |
*/ | |
public function __construct(MyClass1 $object1, MyClass2 $object2, MyClass3 $object3) { | |
$this->obj1 = object1; | |
$this->obj2 = object2; | |
$this->obj3 = object3; | |
} | |
/** | |
* Accessor for obj1 | |
* | |
* @return MyClass1 | |
* The object | |
*/ | |
public function getObject1() { | |
return $this->obj1; | |
} | |
/** | |
* Business logic. | |
*/ | |
protected function businessLogic() { | |
// Do stuff from class 1 | |
$this->getObject1()->methodClass1(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment