/** * Client constructor. * @param array $config */ public function __construct($config = []) { $config = new Config($config); if (!$config->hasRequired()) { throw new NotExistRequiredException(); } parent::__construct($config->toGuzzleConfig()); }
public function testHasRequired() { $config = new Config(['subdomain' => 'test', 'login' => '*****@*****.**', 'password' => 'password']); self::assertTrue($config->hasRequired()); $config = new Config(['subdomain' => 'test', 'use_api_token' => true, 'token' => 'test_token']); self::assertTrue($config->hasRequired()); $config = new Config(['login' => '*****@*****.**', 'password' => 'password']); self::assertFalse($config->hasRequired()); $config = new Config(['subdomain' => 'test', 'login' => '*****@*****.**']); self::assertFalse($config->hasRequired()); $config = new Config(['subdomain' => 'test', 'password' => 'password']); self::assertFalse($config->hasRequired()); $config = new Config(['subdomain' => 'test', 'use_api_token' => true]); self::assertFalse($config->hasRequired()); }