1 | <?php |
||
25 | class TranslateClient |
||
26 | { |
||
27 | /** |
||
28 | * @var Translator |
||
29 | */ |
||
30 | private static $translatorInstance; |
||
31 | |||
32 | /** |
||
33 | * Class constructor. |
||
34 | * |
||
35 | * For more information about HTTP client configuration options, visit |
||
36 | * "Creating a client" section of GuzzleHttp docs. |
||
37 | * 5.x - http://guzzle.readthedocs.org/en/5.3/clients.html#creating-a-client |
||
38 | * |
||
39 | * @param string $source Source language (Optional) |
||
40 | * @param string $target Target language (Optional) |
||
41 | * @param array $options Associative array of http client configuration options (Optional) |
||
42 | * |
||
43 | * @throws Exception If token provider does not implement TokenProviderInterface |
||
44 | */ |
||
45 | public function __construct($source = null, $target = 'en', $options = [], TokenProviderInterface $tokener = null) |
||
52 | |||
53 | /** |
||
54 | * Returns the singleton instance of Translator. |
||
55 | * |
||
56 | * @param TokenProviderInterface|null $tokener |
||
57 | * |
||
58 | * @return Translator |
||
59 | */ |
||
60 | protected static function getInstance(TokenProviderInterface $tokener = null) |
||
68 | |||
69 | /** |
||
70 | * Override translate method for static call. |
||
71 | * |
||
72 | * @throws BadMethodCallException If calling nonexistent method |
||
73 | * @throws InvalidArgumentException If parameters are passed incorrectly |
||
74 | * @throws InvalidArgumentException If the provided argument is not of type 'string' |
||
75 | * @throws ErrorException If the HTTP request fails |
||
76 | * @throws UnexpectedValueException If received data cannot be decoded |
||
77 | */ |
||
78 | public static function __callStatic($name, $args) |
||
101 | |||
102 | /** |
||
103 | * Override translate method for instance call. |
||
104 | * |
||
105 | * @throws BadMethodCallException If calling nonexistent method |
||
106 | * @throws InvalidArgumentException If parameters are passed incorrectly |
||
107 | * @throws InvalidArgumentException If the provided argument is not of type 'string' |
||
108 | * @throws ErrorException If the HTTP request fails |
||
109 | * @throws UnexpectedValueException If received data cannot be decoded |
||
110 | */ |
||
111 | public function __call($methodName, $args) |
||
125 | |||
126 | /** |
||
127 | * Check if given locale is valid. |
||
128 | * |
||
129 | * @param string $lang Language code to verify |
||
130 | * |
||
131 | * @return bool |
||
132 | */ |
||
133 | public static function isValidLocale($lang) |
||
137 | } |
||
138 |