Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. <?php
  2.  
  3. interface Testable{}
  4.  
  5.  
  6.  
  7. class ApiTest implements Testable {
  8.  
  9. public function test()
  10. {
  11. echo 'Api test';
  12. }
  13. }
  14.  
  15. class WebTest implements Testable {
  16.  
  17. public function test()
  18. {
  19. echo 'Web test';
  20. }
  21.  
  22. }
  23.  
  24.  
  25. Class Tester {
  26.  
  27. private $testers;
  28.  
  29. public function __construct(Testable ...$testers) {
  30. $this->testers = $testers;
  31. }
  32.  
  33. public function tests()
  34. {
  35. foreach($this->testers as $tester)
  36. {
  37. $tester->test();
  38. }
  39. }
  40. }
  41.  
  42. $t = new Tester(...[new ApiTest(), new WebTest()]);
  43.  
  44. $t->tests();
  45.  
  46. /* Output
  47. *
  48. * Api test
  49. * Web test
  50. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement