Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php
  2.  
  3. class DatabaseConnection {
  4.  
  5. /** @var string */
  6. protected $host;
  7.  
  8. /** @var string */
  9. protected $user;
  10.  
  11. /** @var string */
  12. protected $password;
  13.  
  14. ...
  15.  
  16. /**
  17. * @param string $host
  18. * @param string $user
  19. * @param string $password
  20. */
  21. public function __construct($host, $user, $password, ...) {
  22. $this->host = $host;
  23. $this->user = $user;
  24. $this->password = $password;
  25. ...
  26. }
  27.  
  28. ...
  29. }
  30.  
  31. class UserFacade {
  32.  
  33. /** @var DatabaseConnection */
  34. protected $databaseConnection;
  35.  
  36. /**
  37. * @param DatabaseConnection $databaseConnection
  38. */
  39. public function __construct(DatabaseConnection $databaseConnection) {
  40. $this->databaseConnection = $databaseConnection;
  41. }
  42.  
  43. /**
  44. * @return array
  45. */
  46. public function getUsers() {
  47. $results = $this->databaseConnection->query('SELECT name FROM user');
  48.  
  49. sort($results);
  50.  
  51. return $results;
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement