@@ -63,7 +63,7 @@ |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
66 | - * @param $text |
|
66 | + * @param string $text |
|
67 | 67 | * @return Payload |
68 | 68 | */ |
69 | 69 | public function getPayload($text) |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Constructor |
22 | - * @param $secretKey |
|
23 | - * @param $accessKey |
|
22 | + * @param string $secretKey |
|
23 | + * @param string $accessKey |
|
24 | 24 | */ |
25 | 25 | public function __construct($secretKey, $accessKey) |
26 | 26 | { |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Set post data |
84 | - * @param array $postData |
|
84 | + * @param string $postData |
|
85 | 85 | * @return $this |
86 | 86 | */ |
87 | 87 | public function setPostData($postData) |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | /** |
94 | 94 | * Get authorization headers |
95 | 95 | * @param string $serviceType |
96 | - * @return array |
|
96 | + * @return string[] |
|
97 | 97 | */ |
98 | 98 | public function getHeader($serviceType) |
99 | 99 | { |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | /** |
137 | 137 | * Get string to sign |
138 | - * @param $canonical |
|
138 | + * @param string $canonical |
|
139 | 139 | * @return string |
140 | 140 | */ |
141 | 141 | protected function getStringToSign($canonical) |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | /** |
168 | 168 | * Create signature |
169 | - * @param $requestType |
|
169 | + * @param string $requestType |
|
170 | 170 | * @return string |
171 | 171 | */ |
172 | 172 | protected function createSignature($requestType) |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | public function getHeader($serviceType) |
99 | 99 | { |
100 | 100 | return [ |
101 | - 'X-Amz-Date: ' . $this->currentTime, |
|
101 | + 'X-Amz-Date: '.$this->currentTime, |
|
102 | 102 | 'Authorization: AWS4-HMAC-SHA256 Credential=' |
103 | 103 | . $this->getCredential() |
104 | 104 | . ',SignedHeaders=host,Signature=' |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | protected function getCredential() |
113 | 113 | { |
114 | - return $this->getAccessKey() . "/" . $this->currentDate . "/eu-west-1/tts/aws4_request"; |
|
114 | + return $this->getAccessKey()."/".$this->currentDate."/eu-west-1/tts/aws4_request"; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -123,13 +123,13 @@ discard block |
||
123 | 123 | protected function getCanonicalRequest($service, $payload = null) |
124 | 124 | { |
125 | 125 | $canonical = |
126 | - "POST" . |
|
127 | - "\n/$service" . |
|
128 | - "\n" . |
|
129 | - "\nhost:tts.eu-west-1.ivonacloud.com" . |
|
130 | - "\n" . |
|
131 | - "\nhost" . |
|
132 | - "\n" . hash("sha256", $payload); |
|
126 | + "POST". |
|
127 | + "\n/$service". |
|
128 | + "\n". |
|
129 | + "\nhost:tts.eu-west-1.ivonacloud.com". |
|
130 | + "\n". |
|
131 | + "\nhost". |
|
132 | + "\n".hash("sha256", $payload); |
|
133 | 133 | return $canonical; |
134 | 134 | } |
135 | 135 | |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | */ |
141 | 141 | protected function getStringToSign($canonical) |
142 | 142 | { |
143 | - $stringToSign = "AWS4-HMAC-SHA256" . |
|
144 | - "\n$this->currentTime" . |
|
145 | - "\n$this->currentDate/eu-west-1/tts/aws4_request" . |
|
146 | - "\n" . hash("sha256", $canonical); |
|
143 | + $stringToSign = "AWS4-HMAC-SHA256". |
|
144 | + "\n$this->currentTime". |
|
145 | + "\n$this->currentDate/eu-west-1/tts/aws4_request". |
|
146 | + "\n".hash("sha256", $canonical); |
|
147 | 147 | |
148 | 148 | return $stringToSign; |
149 | 149 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | */ |
156 | 156 | protected function getSignature($stringToSign) |
157 | 157 | { |
158 | - $dateKey = hash_hmac('sha256', $this->currentDate, "AWS4" . $this->getSecretKey(), true); |
|
158 | + $dateKey = hash_hmac('sha256', $this->currentDate, "AWS4".$this->getSecretKey(), true); |
|
159 | 159 | $dateRegionKey = hash_hmac('sha256', "eu-west-1", $dateKey, true); |
160 | 160 | $dateRegionServiceKey = hash_hmac('sha256', "tts", $dateRegionKey, true); |
161 | 161 | $signingKey = hash_hmac('sha256', "aws4_request", $dateRegionServiceKey, true); |
@@ -17,9 +17,9 @@ |
||
17 | 17 | */ |
18 | 18 | public function setOption($name, $value) |
19 | 19 | { |
20 | - $methodName = 'set' . ucfirst($name); |
|
20 | + $methodName = 'set'.ucfirst($name); |
|
21 | 21 | if (!method_exists($this, $methodName)) { |
22 | - throw new RuntimeException('Method not exists: ' . $methodName); |
|
22 | + throw new RuntimeException('Method not exists: '.$methodName); |
|
23 | 23 | } |
24 | 24 | $this->$methodName($value); |
25 | 25 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $headers = [ |
43 | 43 | 'Content-Type: application/json', |
44 | 44 | 'Host: tts.eu-west-1.ivonacloud.com', |
45 | - 'User-Agent: ' . $this->getOptions()->getUserAgent() |
|
45 | + 'User-Agent: '.$this->getOptions()->getUserAgent() |
|
46 | 46 | ]; |
47 | 47 | |
48 | 48 | return array_merge( |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function createPayload() |
59 | 59 | { |
60 | - $payloadArray = (object)array(); |
|
60 | + $payloadArray = (object) array(); |
|
61 | 61 | $payloadArray->Input['Data'] = $this->getQueryText(); |
62 | 62 | $payloadArray->Input['Type'] = 'text/plain'; |
63 | 63 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function getServiceUrl() |
99 | 99 | { |
100 | - return $this->serviceUrl . '/' . self::SERVICE_TYPE_SPEECH; |
|
100 | + return $this->serviceUrl.'/'.self::SERVICE_TYPE_SPEECH; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $reflection = new \ReflectionObject($this); |
112 | 112 | $constants = $reflection->getConstants(); |
113 | 113 | if (!in_array($serviceType, $constants)) { |
114 | - throw new RuntimeException('Service type does not supports: ' . $serviceType); |
|
114 | + throw new RuntimeException('Service type does not supports: '.$serviceType); |
|
115 | 115 | } |
116 | 116 | return $serviceType; |
117 | 117 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Get service headers |
38 | - * @return array |
|
38 | + * @return string[] |
|
39 | 39 | */ |
40 | 40 | public function getHeaders() |
41 | 41 | { |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Set payload |
84 | - * @param $payload |
|
84 | + * @param string $payload |
|
85 | 85 | * @return $this |
86 | 86 | */ |
87 | 87 | public function setPayload($payload) |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | /** |
94 | 94 | * Get post data for service |
95 | - * @return array |
|
95 | + * @return string |
|
96 | 96 | */ |
97 | 97 | public function getPayload() |
98 | 98 | { |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
112 | - * @return array |
|
112 | + * @return boolean |
|
113 | 113 | */ |
114 | 114 | public function isRussian() |
115 | 115 | { |
@@ -24,8 +24,8 @@ |
||
24 | 24 | $coverage = ($totalElements === 0) ? 0 : ($checkedElements / $totalElements) * 100; |
25 | 25 | |
26 | 26 | if ($coverage < $percentage) { |
27 | - echo 'Code coverage is ' . $coverage . '%, which is below the accepted ' . $percentage . '%' . PHP_EOL; |
|
27 | + echo 'Code coverage is '.$coverage.'%, which is below the accepted '.$percentage.'%'.PHP_EOL; |
|
28 | 28 | exit(1); |
29 | 29 | } |
30 | 30 | |
31 | -echo 'Code coverage is ' . $coverage . '% - OK!' . PHP_EOL; |
|
31 | +echo 'Code coverage is '.$coverage.'% - OK!'.PHP_EOL; |
@@ -86,19 +86,19 @@ discard block |
||
86 | 86 | $encodedData = $this->authenticate->getPostData(); |
87 | 87 | |
88 | 88 | $canonical = |
89 | - "POST\n/" . Payload::SERVICE_TYPE_SPEECH . |
|
90 | - "\n\nhost:tts.eu-west-1.ivonacloud.com\n" . |
|
91 | - "\nhost\n" . hash("sha256", $encodedData); |
|
89 | + "POST\n/".Payload::SERVICE_TYPE_SPEECH. |
|
90 | + "\n\nhost:tts.eu-west-1.ivonacloud.com\n". |
|
91 | + "\nhost\n".hash("sha256", $encodedData); |
|
92 | 92 | |
93 | - $stringToSign = "AWS4-HMAC-SHA256" . |
|
94 | - "\n" . $currentTime->getValue($this->authenticate) . |
|
95 | - "\n" . $currentData->getValue($this->authenticate) . "/eu-west-1/tts/aws4_request" . |
|
96 | - "\n" . hash("sha256", $canonical); |
|
93 | + $stringToSign = "AWS4-HMAC-SHA256". |
|
94 | + "\n".$currentTime->getValue($this->authenticate). |
|
95 | + "\n".$currentData->getValue($this->authenticate)."/eu-west-1/tts/aws4_request". |
|
96 | + "\n".hash("sha256", $canonical); |
|
97 | 97 | |
98 | 98 | $dateKey = hash_hmac( |
99 | 99 | 'sha256', |
100 | 100 | $currentData->getValue($this->authenticate), |
101 | - "AWS4" . $this->authenticate->getSecretKey(), |
|
101 | + "AWS4".$this->authenticate->getSecretKey(), |
|
102 | 102 | true |
103 | 103 | ); |
104 | 104 | $dateRegionKey = hash_hmac('sha256', "eu-west-1", $dateKey, true); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | $credentialMethod = self::getMethod('getCredential'); |
110 | 110 | $expectHeader = [ |
111 | - 'X-Amz-Date: ' . $currentTime->getValue($this->authenticate), |
|
111 | + 'X-Amz-Date: '.$currentTime->getValue($this->authenticate), |
|
112 | 112 | 'Authorization: AWS4-HMAC-SHA256 Credential=' |
113 | 113 | . $credentialMethod->invoke($this->authenticate) |
114 | 114 | . ',SignedHeaders=host,Signature=' |