also looking at this
meemalabs/laravel-text-to-speech
Apply fixes from StyleCI
#31
15 files
+55
-58
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -7,9 +7,8 @@ interface Converter | ||
| 7 | 7 | /** |
| 8 | 8 | * Converts text to speech. |
| 9 | 9 | * |
| 10 | * @param string $text | |
| 11 | * @param array|null $options | |
| 12 | * | |
| 10 | * @param string $text | |
| 11 | * @param array|null $options | |
| 13 | 12 | * @return mixed |
| 14 | 13 | */ |
| 15 | 14 | public function convert(string $text, array $options = null); |
| @@ -17,7 +16,7 @@ interface Converter formatting only | ||
| 17 | 16 | /** |
| 18 | 17 | * Set where to store the converted file. |
| 19 | 18 | * |
| 20 | * @param string $disk | |
| 19 | * @param string $disk | |
| 21 | 20 | * @return $this |
| 22 | 21 | */ |
| 23 | 22 | public function disk(string $disk); |
| @@ -25,7 +24,7 @@ interface Converter formatting only | ||
| 25 | 24 | /** |
| 26 | 25 | * Set path to where to save the converted file. |
| 27 | 26 | * |
| 28 | * @param string $path | |
| 27 | * @param string $path | |
| 29 | 28 | * @return $this |
| 30 | 29 | */ |
| 31 | 30 | public function saveTo(string $path); |
| @@ -33,7 +32,7 @@ interface Converter formatting only | ||
| 33 | 32 | /** |
| 34 | 33 | * Sets the source where the text from. |
| 35 | 34 | * |
| 36 | * @param string $source | |
| 35 | * @param string $source | |
| 37 | 36 | * @return $this |
| 38 | 37 | */ |
| 39 | 38 | public function source(string $source); |
| @@ -41,7 +40,7 @@ interface Converter formatting only | ||
| 41 | 40 | /** |
| 42 | 41 | * Sets the language to be used. |
| 43 | 42 | * |
| 44 | * @param string $language | |
| 43 | * @param string $language | |
| 45 | 44 | * @return $this |
| 46 | 45 | */ |
| 47 | 46 | public function language(string $language); |
| @@ -7,9 +7,8 @@ interface Formatter | ||
| 7 | 7 | /** |
| 8 | 8 | * Handles the filename of the audio. |
| 9 | 9 | * |
| 10 | * @param string $text The text source | |
| 11 | * @param mixed $audio The result audio content. | |
| 12 | * | |
| 10 | * @param string $text The text source | |
| 11 | * @param mixed $audio The result audio content. | |
| 13 | 12 | * @return string |
| 14 | 13 | */ |
| 15 | 14 | public function handle($text, $audio = null): string; |
| @@ -15,9 +15,8 @@ class NullConverter implements Converter | ||
| 15 | 15 | /** |
| 16 | 16 | * Converts the text to speech. |
| 17 | 17 | * |
| 18 | * @param mixed $data | |
| 19 | * @param array|null $options | |
| 20 | * | |
| 18 | * @param mixed $data | |
| 19 | * @param array|null $options | |
| 21 | 20 | * @return string |
| 22 | 21 | */ |
| 23 | 22 | public function convert($data, array $options = null) |
| @@ -26,7 +26,7 @@ class PollyConverter implements Converter formatting only | ||
| 26 | 26 | /** |
| 27 | 27 | * Construct converter. |
| 28 | 28 | * |
| 29 | * @param PollyClient $client | |
| 29 | * @param PollyClient $client | |
| 30 | 30 | */ |
| 31 | 31 | public function __construct(PollyClient $client) |
| 32 | 32 | { |
| @@ -46,9 +46,8 @@ class PollyConverter implements Converter | ||
| 46 | 46 | /** |
| 47 | 47 | * Converts the text to speech. |
| 48 | 48 | * |
| 49 | * @param string $data | |
| 50 | * @param array|null $options | |
| 51 | * | |
| 49 | * @param string $data | |
| 50 | * @param array|null $options | |
| 52 | 51 | * @return string|array |
| 53 | 52 | */ |
| 54 | 53 | public function convert(string $data, array $options = null) |
| @@ -82,9 +81,8 @@ class PollyConverter implements Converter | ||
| 82 | 81 | /** |
| 83 | 82 | * Request to Amazon Polly to synthesize speech. |
| 84 | 83 | * |
| 85 | * @param string|array $text | |
| 86 | * @param array|null $options | |
| 87 | * | |
| 84 | * @param string|array $text | |
| 85 | * @param array|null $options | |
| 88 | 86 | * @return array|\Aws\Result |
| 89 | 87 | */ |
| 90 | 88 | protected function synthesizeSpeech($text, array $options = null) |
| @@ -137,7 +135,7 @@ class PollyConverter implements Converter formatting only | ||
| 137 | 135 | /** |
| 138 | 136 | * Checks the length of the text if more than 3000. |
| 139 | 137 | * |
| 140 | * @param string $text | |
| 138 | * @param string $text | |
| 141 | 139 | * @return bool |
| 142 | 140 | */ |
| 143 | 141 | protected function isTextAboveLimit(string $text) |
| @@ -148,8 +146,8 @@ class PollyConverter implements Converter formatting only | ||
| 148 | 146 | /** |
| 149 | 147 | * Chunk the given text into array. |
| 150 | 148 | * |
| 151 | * @param string $text | |
| 152 | * @param int $size | |
| 149 | * @param string $text | |
| 150 | * @param int $size | |
| 153 | 151 | * @return array |
| 154 | 152 | */ |
| 155 | 153 | protected function getChunkText(string $text, int $size = 2000) |
| @@ -160,7 +158,7 @@ class PollyConverter implements Converter formatting only | ||
| 160 | 158 | /** |
| 161 | 159 | * Get the text to speech voice ID. |
| 162 | 160 | * |
| 163 | * @param array $options | |
| 161 | * @param array $options | |
| 164 | 162 | * @return string |
| 165 | 163 | */ |
| 166 | 164 | protected function voice($options) |
| @@ -195,7 +193,7 @@ class PollyConverter implements Converter formatting only | ||
| 195 | 193 | /** |
| 196 | 194 | * Get the audio format. |
| 197 | 195 | * |
| 198 | * @param array $options | |
| 196 | * @param array $options | |
| 199 | 197 | * @return string |
| 200 | 198 | */ |
| 201 | 199 | protected function format($options) |
| @@ -212,7 +210,7 @@ class PollyConverter implements Converter formatting only | ||
| 212 | 210 | /** |
| 213 | 211 | * Get the engine. |
| 214 | 212 | * |
| 215 | * @param array $options | |
| 213 | * @param array $options | |
| 216 | 214 | * @return string |
| 217 | 215 | */ |
| 218 | 216 | protected function engine($options) |
| @@ -235,7 +233,7 @@ class PollyConverter implements Converter formatting only | ||
| 235 | 233 | /** |
| 236 | 234 | * Get the content of the result from AWS Polly. |
| 237 | 235 | * |
| 238 | * @param Result $result | |
| 236 | * @param Result $result | |
| 239 | 237 | * @return mixed |
| 240 | 238 | */ |
| 241 | 239 | protected function getResultContent($result) |
| @@ -256,7 +254,7 @@ class PollyConverter implements Converter formatting only | ||
| 256 | 254 | /** |
| 257 | 255 | * Format the given json string into an array. |
| 258 | 256 | * |
| 259 | * @param string $json | |
| 257 | * @param string $json | |
| 260 | 258 | * @return array |
| 261 | 259 | */ |
| 262 | 260 | protected function formatToArray($json) |
| @@ -9,9 +9,8 @@ class DefaultFilenameFormatter implements FormatterContract | ||
| 9 | 9 | /** |
| 10 | 10 | * Handles the filename of the audio. |
| 11 | 11 | * |
| 12 | * @param string $text The text source. | |
| 13 | * @param mixed $audio The result audio content. | |
| 14 | * | |
| 12 | * @param string $text The text source. | |
| 13 | * @param mixed $audio The result audio content. | |
| 15 | 14 | * @return string |
| 16 | 15 | */ |
| 17 | 16 | public function handle($text, $audio = null): string |
| @@ -9,18 +9,20 @@ class RecursiveDOMIterator implements RecursiveIterator | ||
| 9 | 9 | { |
| 10 | 10 | /** |
| 11 | 11 | * Current Position in DOMNodeList. |
| 12 | * | |
| 12 | 13 | * @var int |
| 13 | 14 | */ |
| 14 | 15 | protected $_position; |
| 15 | 16 | |
| 16 | 17 | /** |
| 17 | 18 | * The DOMNodeList with all children to iterate over. |
| 19 | * | |
| 18 | 20 | * @var DOMNodeList |
| 19 | 21 | */ |
| 20 | 22 | protected $_nodeList; |
| 21 | 23 | |
| 22 | 24 | /** |
| 23 | * @param DOMNode $domNode | |
| 25 | * @param DOMNode $domNode | |
| 24 | 26 | */ |
| 25 | 27 | public function __construct(DOMNode $domNode) |
| 26 | 28 | { |
| @@ -30,6 +32,7 @@ class RecursiveDOMIterator implements RecursiveIterator | ||
| 30 | 32 | |
| 31 | 33 | /** |
| 32 | 34 | * Returns the current DOMNode. |
| 35 | * | |
| 33 | 36 | * @return DOMNode |
| 34 | 37 | */ |
| 35 | 38 | public function current() |
| @@ -39,6 +42,7 @@ class RecursiveDOMIterator implements RecursiveIterator | ||
| 39 | 42 | |
| 40 | 43 | /** |
| 41 | 44 | * Returns an iterator for the current iterator entry. |
| 45 | * | |
| 42 | 46 | * @return RecursiveDOMIterator |
| 43 | 47 | */ |
| 44 | 48 | public function getChildren() |
| @@ -48,6 +52,7 @@ class RecursiveDOMIterator implements RecursiveIterator | ||
| 48 | 52 | |
| 49 | 53 | /** |
| 50 | 54 | * Returns if an iterator can be created for the current entry. |
| 55 | * | |
| 51 | 56 | * @return bool |
| 52 | 57 | */ |
| 53 | 58 | public function hasChildren() |
| @@ -57,6 +62,7 @@ class RecursiveDOMIterator implements RecursiveIterator | ||
| 57 | 62 | |
| 58 | 63 | /** |
| 59 | 64 | * Returns the current position. |
| 65 | * | |
| 60 | 66 | * @return int |
| 61 | 67 | */ |
| 62 | 68 | public function key() |
| @@ -66,6 +72,7 @@ class RecursiveDOMIterator implements RecursiveIterator | ||
| 66 | 72 | |
| 67 | 73 | /** |
| 68 | 74 | * Moves the current position to the next element. |
| 75 | * | |
| 69 | 76 | * @return void |
| 70 | 77 | */ |
| 71 | 78 | public function next() |
| @@ -75,6 +82,7 @@ class RecursiveDOMIterator implements RecursiveIterator | ||
| 75 | 82 | |
| 76 | 83 | /** |
| 77 | 84 | * Rewind the Iterator to the first element. |
| 85 | * | |
| 78 | 86 | * @return void |
| 79 | 87 | */ |
| 80 | 88 | public function rewind() |
| @@ -84,6 +92,7 @@ class RecursiveDOMIterator implements RecursiveIterator | ||
| 84 | 92 | |
| 85 | 93 | /** |
| 86 | 94 | * Checks if current position is valid. |
| 95 | * | |
| 87 | 96 | * @return bool |
| 88 | 97 | */ |
| 89 | 98 | public function valid() |
| @@ -12,7 +12,7 @@ class WebsiteSource implements SourceContract | ||
| 12 | 12 | /** |
| 13 | 13 | * Handles in getting the text from source. |
| 14 | 14 | * |
| 15 | * @param string $data | |
| 15 | * @param string $data | |
| 16 | 16 | * @return string |
| 17 | 17 | */ |
| 18 | 18 | public function handle(string $data): string |
| @@ -45,7 +45,7 @@ class WebsiteSource implements SourceContract | ||
| 45 | 45 | /** |
| 46 | 46 | * Get text from the articles DOM Node List. |
| 47 | 47 | * |
| 48 | * @param DOMNodeList $articles | |
| 48 | * @param DOMNodeList $articles | |
| 49 | 49 | * @return string |
| 50 | 50 | */ |
| 51 | 51 | protected function getTextFromArticle(DOMNodeList $articles): string |
| @@ -45,8 +45,8 @@ class TextToSpeechManager extends Manager | ||
| 45 | 45 | /** |
| 46 | 46 | * Sets the polly client. |
| 47 | 47 | * |
| 48 | * @param array $config | |
| 49 | * @param Credentials $credentials | |
| 48 | * @param array $config | |
| 49 | * @param Credentials $credentials | |
| 50 | 50 | * @return PollyClient |
| 51 | 51 | */ |
| 52 | 52 | protected function setPollyClient(array $config, Credentials $credentials) |
| @@ -61,7 +61,7 @@ class TextToSpeechManager extends Manager | ||
| 61 | 61 | /** |
| 62 | 62 | * Get credentials of AWS. |
| 63 | 63 | * |
| 64 | * @param array $credentials | |
| 64 | * @param array $credentials | |
| 65 | 65 | * @return \Aws\Credentials\Credentials |
| 66 | 66 | */ |
| 67 | 67 | protected function getCredentials(array $credentials) |
| @@ -16,7 +16,7 @@ trait Sourceable formatting only | ||
| 16 | 16 | /** |
| 17 | 17 | * Sets the source. |
| 18 | 18 | * |
| 19 | * @param string $source | |
| 19 | * @param string $source | |
| 20 | 20 | * @return $this |
| 21 | 21 | */ |
| 22 | 22 | public function source(string $source) |
| @@ -29,8 +29,7 @@ trait Sourceable | ||
| 29 | 29 | /** |
| 30 | 30 | * Get text from source. |
| 31 | 31 | * |
| 32 | * @param string $data | |
| 33 | * | |
| 32 | * @param string $data | |
| 34 | 33 | * @return string |
| 35 | 34 | */ |
| 36 | 35 | protected function getTextFromSource(string $data): string |
| @@ -24,8 +24,7 @@ trait Storable | ||
| 24 | 24 | /** |
| 25 | 25 | * Set where to store the converted file. |
| 26 | 26 | * |
| 27 | * @param string $disk | |
| 28 | * | |
| 27 | * @param string $disk | |
| 29 | 28 | * @return $this |
| 30 | 29 | */ |
| 31 | 30 | public function disk(string $disk) |
| @@ -38,8 +37,7 @@ trait Storable | ||
| 38 | 37 | /** |
| 39 | 38 | * Set path to where to store the converted file. |
| 40 | 39 | * |
| 41 | * @param string $path | |
| 42 | * | |
| 40 | * @param string $path | |
| 43 | 41 | * @return $this |
| 44 | 42 | */ |
| 45 | 43 | public function saveTo(string $path) |
| @@ -52,9 +50,8 @@ trait Storable | ||
| 52 | 50 | /** |
| 53 | 51 | * Execute the store. |
| 54 | 52 | * |
| 55 | * @param string $text | |
| 56 | * @param mixed $resultContent | |
| 57 | * | |
| 53 | * @param string $text | |
| 54 | * @param mixed $resultContent | |
| 58 | 55 | * @return string |
| 59 | 56 | */ |
| 60 | 57 | protected function store($text, $resultContent) |
| @@ -71,9 +68,8 @@ trait Storable | ||
| 71 | 68 | /** |
| 72 | 69 | * Ensures the path not to be null if it is null it will set a default path. |
| 73 | 70 | * |
| 74 | * @param string $text | |
| 75 | * @param mixed $audio | |
| 76 | * | |
| 71 | * @param string $text | |
| 72 | * @param mixed $audio | |
| 77 | 73 | * @return void |
| 78 | 74 | */ |
| 79 | 75 | protected function ensurePathIsNotNull($text, $audio) |
| @@ -111,9 +107,8 @@ trait Storable | ||
| 111 | 107 | /** |
| 112 | 108 | * Get default filename returned in Filename Formatter. |
| 113 | 109 | * |
| 114 | * @param string $text | |
| 115 | * @param mixed $audio | |
| 116 | * | |
| 110 | * @param string $text | |
| 111 | * @param mixed $audio | |
| 117 | 112 | * @return string |
| 118 | 113 | */ |
| 119 | 114 | protected function getDefaultFilename($text, $audio) |