Skip to content

Instantly share code, notes, and snippets.

@e0ipso
Last active August 29, 2015 14:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e0ipso/77ef4c4dba8c3659485a to your computer and use it in GitHub Desktop.
Save e0ipso/77ef4c4dba8c3659485a to your computer and use it in GitHub Desktop.
Accessors and mutators
<?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