getProvider() public method

Gets provider object by name. If there is no such provider in providers array, it will try to create it, then save it, and then return.
public getProvider ( string $provider ) : Provider
$provider string
return seregazhuk\PinterestBot\Api\Providers\Provider
 /**
  * @test
  * @expectedException \seregazhuk\PinterestBot\Exceptions\WrongProviderException
  */
 public function getWrongProvider()
 {
     $this->container->getProvider('unknown');
 }
Example #2
0
 /**
  * Magic method to access different providers from the providers container.
  *
  * @param string $provider
  * @return Provider
  */
 public function __get($provider)
 {
     return $this->providersContainer->getProvider($provider);
 }
 /**
  * @test
  * @expectedException \seregazhuk\PinterestBot\Exceptions\WrongProvider
  */
 public function it_should_throw_exception_on_getting_wrong_provider()
 {
     $this->container->getProvider('unknown');
 }