chobie\Jira\Api::__construct PHP Method

__construct() public method

Create a JIRA API client.
public __construct ( string $endpoint, chobie\Jira\Api\Authentication\AuthenticationInterface $authentication, chobie\Jira\Api\Client\ClientInterface $client = null )
$endpoint string Endpoint URL.
$authentication chobie\Jira\Api\Authentication\AuthenticationInterface Authentication.
$client chobie\Jira\Api\Client\ClientInterface Client.
    public function __construct($endpoint, AuthenticationInterface $authentication, ClientInterface $client = null)
    {
        $this->setEndPoint($endpoint);
        $this->authentication = $authentication;
        if (is_null($client)) {
            $client = new CurlClient();
        }
        $this->client = $client;
    }

Usage Example

Example #1
0
 /**
  * Check credentials
  *
  * @param string                  $endpoint
  * @param AuthenticationInterface $authentication
  * @param ClientInterface         $client
  * @throws Api\Exception
  */
 public function __construct($endpoint, AuthenticationInterface $authentication, ClientInterface $client = null)
 {
     if (!$authentication->getId() || !$authentication->getPassword()) {
         throw new Api\Exception('Username or password is empty.', self::ERROR_EMPTY_CREDENTIALS);
     }
     parent::__construct($endpoint, $authentication, $client);
 }