Advertisement
Guest User

Untitled

a guest
Sep 1st, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. interface ProviderInterface
  2. {
  3.  
  4. const TYPE_ELECTRICITY = 'electricity';
  5.  
  6. const TYPE_GAS = 'gas';
  7.  
  8. /**
  9. * @param ContainerInterface $container
  10. *
  11. * @return void
  12. */
  13. function setContainer(ContainerInterface $container);
  14.  
  15. /**
  16. * @return Client|SoapClient
  17. */
  18. function client();
  19.  
  20. }
  21.  
  22. trait ProviderTrait
  23. {
  24.  
  25. /**
  26. * @var string
  27. */
  28. private $endpoint = '';
  29.  
  30.  
  31. public function setContainer($container) {
  32. /** void for demo purposes */
  33. }
  34. }
  35.  
  36.  
  37. class Provider implements ProviderInterface
  38. {
  39.  
  40. use ProviderTrait;
  41.  
  42. /**
  43. * @var string
  44. */
  45. private $username;
  46.  
  47. /**
  48. * @var string
  49. */
  50. private $password;
  51.  
  52. /**
  53. * constructor.
  54. *
  55. * @param ContainerInterface $container
  56. */
  57. final public function __construct(ContainerInterface $container)
  58. {
  59. $this->setContainer($container);
  60.  
  61. /**
  62. * While $username and $password are declared within this class, the $endpoint is declared in the ProviderTrait. PHP works fine. PhpStorm ignores it and says it is declared "dynamically".
  63. */
  64. $this->endpoint = $this->container->getParameter('api.endpoint');
  65. $this->username = $this->container->getParameter('api.username');
  66. $this->password = $this->container->getParameter('api.password');
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement