1 | <?php |
||
23 | abstract class TransifexObject |
||
24 | { |
||
25 | /** |
||
26 | * Options for the Transifex object. |
||
27 | * |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $options; |
||
31 | |||
32 | /** |
||
33 | * The HTTP client object to use in sending HTTP requests. |
||
34 | * |
||
35 | * @var ClientInterface |
||
36 | */ |
||
37 | protected $client; |
||
38 | |||
39 | /** |
||
40 | * @param array $options Transifex options array |
||
41 | * @param ClientInterface $client The HTTP client object |
||
42 | */ |
||
43 | 1 | public function __construct(array $options = [], ClientInterface $client = null) |
|
48 | |||
49 | /** |
||
50 | * Create a Uri object for the path |
||
51 | * |
||
52 | * @param string $path |
||
53 | * |
||
54 | * @return Uri |
||
55 | */ |
||
56 | protected function createUri(string $path) : Uri |
||
62 | |||
63 | /** |
||
64 | * Get the authentication credentials for the API request. |
||
65 | * |
||
66 | * @return array |
||
67 | * |
||
68 | * @throws \InvalidArgumentException if credentials are not set |
||
69 | */ |
||
70 | 71 | protected function getAuthData() : array |
|
82 | |||
83 | /** |
||
84 | * Get an option from the options store. |
||
85 | * |
||
86 | * @param string $key The name of the option to get |
||
87 | * @param mixed $default The default value if the option is not set |
||
88 | * |
||
89 | * @return mixed The option value |
||
90 | */ |
||
91 | 1 | protected function getOption(string $key, $default = null) |
|
95 | |||
96 | /** |
||
97 | * Update an API endpoint with resource content. |
||
98 | * |
||
99 | * @param UriInterface $uri URI object representing the API path to request |
||
100 | * @param string $content The content of the resource, this can either be a string of data or a file path |
||
101 | * @param string $type The type of content in the $content variable, this should be either string or file |
||
102 | * |
||
103 | * @return ResponseInterface |
||
104 | * |
||
105 | * @throws \InvalidArgumentException |
||
106 | */ |
||
107 | 9 | protected function updateResource(UriInterface $uri, string $content, string $type) : ResponseInterface |
|
138 | } |
||
139 |