Last active
January 26, 2018 18:46
-
-
Save zabaala/b6dd88b371d2e2ae6e6bb90b55e5e6ab to your computer and use it in GitHub Desktop.
BadAbstractRepository.php
This file contains hidden or 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 | |
| abstract class BadAbstractRepository | |
| { | |
| protected $model; | |
| /** | |
| * Recupera todas as entidades de forma genérica. | |
| */ | |
| public function getAll() | |
| { | |
| return $this->model->get(); | |
| } | |
| /** | |
| * Recupera todas as entidades por ID de forma genérica... | |
| */ | |
| public function find($id) | |
| { | |
| return $this->model->find($id); | |
| } | |
| /** | |
| * Atualiza uma entidade por ID de forma genérica... | |
| */ | |
| public function update($id, array $attributes) | |
| { | |
| return $this->model->find($id)->update($attributes); | |
| } | |
| // etc... | |
| } |
This file contains hidden or 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 BadUserRepository extends BadAbstractRepository implements UserRepository | |
| { | |
| public function __construct() | |
| { | |
| $this->model = new User(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment