1 | <?php |
||
26 | class Crowdin |
||
27 | { |
||
28 | /** |
||
29 | * The Crowdin project id. |
||
30 | * @var string |
||
31 | */ |
||
32 | private $projectId; |
||
33 | |||
34 | /** |
||
35 | * The Crowdin API key. |
||
36 | * @var string |
||
37 | */ |
||
38 | private $apiKey; |
||
39 | |||
40 | /** |
||
41 | * The HTTP client object. |
||
42 | * @var HttpClient |
||
43 | */ |
||
44 | private $httpClient; |
||
45 | |||
46 | /** |
||
47 | * Constructor. |
||
48 | * |
||
49 | * @param string $projectId The project ID. |
||
50 | * @param string $apiKey The API key |
||
51 | * @param string $baseUri The base URI |
||
52 | * @param HttpClient $client The HTTP client object. |
||
53 | * |
||
54 | * @since 1.0 |
||
55 | */ |
||
56 | 1 | public function __construct(string $projectId, string $apiKey, string $baseUri = 'https://api.crowdin.com/api/', HttpClient $client = null) |
|
57 | { |
||
58 | 1 | $this->projectId = $projectId; |
|
59 | 1 | $this->apiKey = $apiKey; |
|
60 | |||
61 | 1 | $this->httpClient = $client ?? new HttpClient(['base_uri' => $baseUri]); |
|
62 | 1 | } |
|
63 | |||
64 | /** |
||
65 | * Magic method to lazily create API objects. |
||
66 | * |
||
67 | * @param string $name Name of property to retrieve |
||
68 | * |
||
69 | * @return Object |
||
70 | * |
||
71 | * @since 1.0 |
||
72 | * @throws \InvalidArgumentException If $name is not a valid sub class. |
||
73 | */ |
||
74 | 2 | public function __get(string $name) |
|
90 | } |
||
91 |