Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface ProviderInterface
- {
- const TYPE_ELECTRICITY = 'electricity';
- const TYPE_GAS = 'gas';
- /**
- * @param ContainerInterface $container
- *
- * @return void
- */
- function setContainer(ContainerInterface $container);
- /**
- * @return Client|SoapClient
- */
- function client();
- }
- trait ProviderTrait
- {
- /**
- * @var string
- */
- private $endpoint = '';
- public function setContainer($container) {
- /** void for demo purposes */
- }
- }
- class Provider implements ProviderInterface
- {
- use ProviderTrait;
- /**
- * @var string
- */
- private $username;
- /**
- * @var string
- */
- private $password;
- /**
- * constructor.
- *
- * @param ContainerInterface $container
- */
- final public function __construct(ContainerInterface $container)
- {
- $this->setContainer($container);
- /**
- * 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".
- */
- $this->endpoint = $this->container->getParameter('api.endpoint');
- $this->username = $this->container->getParameter('api.username');
- $this->password = $this->container->getParameter('api.password');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement