ReviewOS

also looking at this

meemalabs/laravel-text-to-speech

Support laravel 9

#32
Merged luigel wants to merge support-laravel-9 into main
17 files +83 -61
.github/workflows/run-tests.ymlmodified+22-3
Changes to .github/workflows/run-tests.yml
@@ -10,16 +10,35 @@ jobs:
1010 strategy:
1111 fail-fast: false
1212 matrix:
13 php: [7.3, 7.4, 8.0]
14 laravel: [6.*, 7.*, 8.*]
15 dependency-version: [prefer-lowest, prefer-stable]
13 php: [7.3, 7.4, 8.0, 8.1]
14 laravel: [6.*, 7.*, 8.*, 9.*]
15 dependency-version: [prefer-stable]
1616 include:
17 - laravel: 9.*
18 testbench: 7.*
1719 - laravel: 8.*
1820 testbench: 6.*
1921 - laravel: 7.*
2022 testbench: 5.*
2123 - laravel: 6.*
2224 testbench: 4.*
25 exclude:
26 - laravel: 6.*
27 php: 8.0
28 - laravel: 6.*
29 php: 8.1
30 - laravel: 7.*
31 php: 8.0
32 - laravel: 7.*
33 php: 8.1
34 - laravel: 9.*
35 php: 7.3
36 - laravel: 9.*
37 php: 7.4
38 - laravel: 8.*
39 php: 7.4
40 - laravel: 8.*
41 php: 7.3
2342
2443 name: P ${{ matrix.php }} - L ${{ matrix.laravel }} - ${{ matrix.dependency-version }}
2544
composer.jsonmodified+2-2
Changes to composer.json
@@ -28,11 +28,11 @@
2828 "php": "^7.3|^7.4|^8.0",
2929 "aws/aws-sdk-php": "^3.178",
3030 "guzzlehttp/guzzle": "^6.0|^7.0",
31 "illuminate/support": "5.*|^6.0|^7.0|^8.0",
31 "illuminate/support": "5.*|^6.0|^7.0|^8.0|^9.0",
3232 "ext-json": "*"
3333 },
3434 "require-dev": {
35 "orchestra/testbench": "^4.0|^5.0|^6.0",
35 "orchestra/testbench": "^4.0|^5.0|^6.0|^7.0",
3636 "phpunit/phpunit": "^5.0|^6.0|^8.0|^9.3"
3737 },
3838 "autoload": {
src/Contracts/Converter.phpmodified+6-6
Changes to src/Contracts/Converter.php
@@ -7,8 +7,8 @@ interface Converter
77 /**
88 * Converts text to speech.
99 *
10 * @param string $text
11 * @param array $options
10 * @param string $text
11 * @param array|null $options
1212 * @return mixed
1313 */
1414 public function convert(string $text, array $options = null);
formatting only · 8 hidden lines
Changes to src/Contracts/Converter.php
@@ -16,7 +16,7 @@ interface Converter formatting only
1616 /**
1717 * Set where to store the converted file.
1818 *
19 * @param string $disk
19 * @param string $disk
2020 * @return $this
2121 */
2222 public function disk(string $disk);
formatting only · 8 hidden lines
Changes to src/Contracts/Converter.php
@@ -24,7 +24,7 @@ interface Converter formatting only
2424 /**
2525 * Set path to where to save the converted file.
2626 *
27 * @param string $path
27 * @param string $path
2828 * @return $this
2929 */
3030 public function saveTo(string $path);
formatting only · 8 hidden lines
Changes to src/Contracts/Converter.php
@@ -32,7 +32,7 @@ interface Converter formatting only
3232 /**
3333 * Sets the source where the text from.
3434 *
35 * @param string $source
35 * @param string $source
3636 * @return $this
3737 */
3838 public function source(string $source);
formatting only · 8 hidden lines
Changes to src/Contracts/Converter.php
@@ -40,7 +40,7 @@ interface Converter formatting only
4040 /**
4141 * Sets the language to be used.
4242 *
43 * @param string $language
43 * @param string $language
4444 * @return $this
4545 */
4646 public function language(string $language);
src/Contracts/Formatter.phpmodified+2-3
Changes to src/Contracts/Formatter.php
@@ -7,9 +7,8 @@ interface Formatter
77 /**
88 * Handles the filename of the audio.
99 *
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.
1312 * @return string
1413 */
1514 public function handle($text, $audio = null): string;
src/Contracts/Source.phpmodifiedformatting only+1-1
Changes to src/Contracts/Source.php
@@ -7,7 +7,7 @@ interface Source
77 /**
88 * Handles in getting the text from source.
99 *
10 * @param string $data
10 * @param string $data
1111 * @return string
1212 */
1313 public function handle(string $data): string;
src/Converters/NullConverter.phpmodified+3-3
Changes to src/Converters/NullConverter.php
@@ -15,9 +15,9 @@ class NullConverter implements Converter
1515 /**
1616 * Converts the text to speech.
1717 *
18 * @param mixed $data
19 * @param array $options
20 * @return void
18 * @param mixed $data
19 * @param array|null $options
20 * @return string
2121 */
2222 public function convert($data, array $options = null)
2323 {
src/Converters/PollyConverter.phpmodified+14-14
formatting only · 8 hidden lines
Changes to src/Converters/PollyConverter.php
@@ -26,7 +26,7 @@ class PollyConverter implements Converter formatting only
2626 /**
2727 * Construct converter.
2828 *
29 * @param PollyClient $client
29 * @param PollyClient $client
3030 */
3131 public function __construct(PollyClient $client)
3232 {
Changes to src/Converters/PollyConverter.php
@@ -46,8 +46,8 @@ class PollyConverter implements Converter
4646 /**
4747 * Converts the text to speech.
4848 *
49 * @param string $data
50 * @param array $options
49 * @param string $data
50 * @param array|null $options
5151 * @return string|array
5252 */
5353 public function convert(string $data, array $options = null)
@@ -81,8 +81,8 @@ class PollyConverter implements Converter
8181 /**
8282 * Request to Amazon Polly to synthesize speech.
8383 *
84 * @param string|array $text
85 * @param array $options
84 * @param string|array $text
85 * @param array|null $options
8686 * @return array|\Aws\Result
8787 */
8888 protected function synthesizeSpeech($text, array $options = null)
@@ -111,7 +111,7 @@ class PollyConverter implements Converter
111111 'Text' => $textItem,
112112 ]));
113113
114 array_push($results, $result);
114 $results[] = $result;
115115 }
116116
117117 return $results;
formatting only · 8 hidden lines
Changes to src/Converters/PollyConverter.php
@@ -135,7 +135,7 @@ class PollyConverter implements Converter formatting only
135135 /**
136136 * Checks the length of the text if more than 3000.
137137 *
138 * @param string $text
138 * @param string $text
139139 * @return bool
140140 */
141141 protected function isTextAboveLimit(string $text)
formatting only · 10 hidden lines
Changes to src/Converters/PollyConverter.php
@@ -146,8 +146,8 @@ class PollyConverter implements Converter formatting only
146146 /**
147147 * Chunk the given text into array.
148148 *
149 * @param string $text
150 * @param int $size
149 * @param string $text
150 * @param int $size
151151 * @return array
152152 */
153153 protected function getChunkText(string $text, int $size = 2000)
formatting only · 8 hidden lines
Changes to src/Converters/PollyConverter.php
@@ -158,7 +158,7 @@ class PollyConverter implements Converter formatting only
158158 /**
159159 * Get the text to speech voice ID.
160160 *
161 * @param array $options
161 * @param array $options
162162 * @return string
163163 */
164164 protected function voice($options)
formatting only · 8 hidden lines
Changes to src/Converters/PollyConverter.php
@@ -193,7 +193,7 @@ class PollyConverter implements Converter formatting only
193193 /**
194194 * Get the audio format.
195195 *
196 * @param array $options
196 * @param array $options
197197 * @return string
198198 */
199199 protected function format($options)
formatting only · 8 hidden lines
Changes to src/Converters/PollyConverter.php
@@ -210,7 +210,7 @@ class PollyConverter implements Converter formatting only
210210 /**
211211 * Get the engine.
212212 *
213 * @param array $options
213 * @param array $options
214214 * @return string
215215 */
216216 protected function engine($options)
formatting only · 8 hidden lines
Changes to src/Converters/PollyConverter.php
@@ -233,7 +233,7 @@ class PollyConverter implements Converter formatting only
233233 /**
234234 * Get the content of the result from AWS Polly.
235235 *
236 * @param Result $result
236 * @param Result $result
237237 * @return mixed
238238 */
239239 protected function getResultContent($result)
formatting only · 8 hidden lines
Changes to src/Converters/PollyConverter.php
@@ -254,7 +254,7 @@ class PollyConverter implements Converter formatting only
254254 /**
255255 * Format the given json string into an array.
256256 *
257 * @param string $json
257 * @param string $json
258258 * @return array
259259 */
260260 protected function formatToArray($json)
src/Formatters/DefaultFilenameFormatter.phpmodified+2-3
Changes to src/Formatters/DefaultFilenameFormatter.php
@@ -9,9 +9,8 @@ class DefaultFilenameFormatter implements FormatterContract
99 /**
1010 * Handles the filename of the audio.
1111 *
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.
1514 * @return string
1615 */
1716 public function handle($text, $audio = null): string
src/Sources/PathSource.phpmodifiedformatting only+1-1
Changes to src/Sources/PathSource.php
@@ -9,7 +9,7 @@ class PathSource implements SourceContract
99 /**
1010 * Handles in getting the text from source.
1111 *
12 * @param string $data
12 * @param string $data
1313 * @return string
1414 */
1515 public function handle(string $data): string
src/Sources/RecursiveDOMIterator.phpmodified+10-1
Changes to src/Sources/RecursiveDOMIterator.php
@@ -9,18 +9,20 @@ class RecursiveDOMIterator implements RecursiveIterator
99{
1010 /**
1111 * Current Position in DOMNodeList.
12 *
1213 * @var int
1314 */
1415 protected $_position;
1516
1617 /**
1718 * The DOMNodeList with all children to iterate over.
19 *
1820 * @var DOMNodeList
1921 */
2022 protected $_nodeList;
2123
2224 /**
23 * @param DOMNode $domNode
25 * @param DOMNode $domNode
2426 */
2527 public function __construct(DOMNode $domNode)
2628 {
@@ -30,6 +32,7 @@ class RecursiveDOMIterator implements RecursiveIterator
3032
3133 /**
3234 * Returns the current DOMNode.
35 *
3336 * @return DOMNode
3437 */
3538 public function current()
@@ -39,6 +42,7 @@ class RecursiveDOMIterator implements RecursiveIterator
3942
4043 /**
4144 * Returns an iterator for the current iterator entry.
45 *
4246 * @return RecursiveDOMIterator
4347 */
4448 public function getChildren()
@@ -48,6 +52,7 @@ class RecursiveDOMIterator implements RecursiveIterator
4852
4953 /**
5054 * Returns if an iterator can be created for the current entry.
55 *
5156 * @return bool
5257 */
5358 public function hasChildren()
@@ -57,6 +62,7 @@ class RecursiveDOMIterator implements RecursiveIterator
5762
5863 /**
5964 * Returns the current position.
65 *
6066 * @return int
6167 */
6268 public function key()
@@ -66,6 +72,7 @@ class RecursiveDOMIterator implements RecursiveIterator
6672
6773 /**
6874 * Moves the current position to the next element.
75 *
6976 * @return void
7077 */
7178 public function next()
@@ -75,6 +82,7 @@ class RecursiveDOMIterator implements RecursiveIterator
7582
7683 /**
7784 * Rewind the Iterator to the first element.
85 *
7886 * @return void
7987 */
8088 public function rewind()
@@ -84,6 +92,7 @@ class RecursiveDOMIterator implements RecursiveIterator
8492
8593 /**
8694 * Checks if current position is valid.
95 *
8796 * @return bool
8897 */
8998 public function valid()
src/Sources/TextSource.phpmodifiedformatting only+1-1
Changes to src/Sources/TextSource.php
@@ -9,7 +9,7 @@ class TextSource implements SourceContract
99 /**
1010 * Handles in getting the text from source.
1111 *
12 * @param string $data
12 * @param string $data
1313 * @return string
1414 */
1515 public function handle(string $data): string
src/Sources/WebsiteSource.phpmodifiedformatting only+2-2
Changes to src/Sources/WebsiteSource.php
@@ -12,7 +12,7 @@ class WebsiteSource implements SourceContract
1212 /**
1313 * Handles in getting the text from source.
1414 *
15 * @param string $data
15 * @param string $data
1616 * @return string
1717 */
1818 public function handle(string $data): string
@@ -45,7 +45,7 @@ class WebsiteSource implements SourceContract
4545 /**
4646 * Get text from the articles DOM Node List.
4747 *
48 * @param DOMNodeList $articles
48 * @param DOMNodeList $articles
4949 * @return string
5050 */
5151 protected function getTextFromArticle(DOMNodeList $articles): string
src/TextToSpeechManager.phpmodifiedformatting only+3-3
Changes to src/TextToSpeechManager.php
@@ -45,8 +45,8 @@ class TextToSpeechManager extends Manager
4545 /**
4646 * Sets the polly client.
4747 *
48 * @param array $config
49 * @param Credentials $credentials
48 * @param array $config
49 * @param Credentials $credentials
5050 * @return PollyClient
5151 */
5252 protected function setPollyClient(array $config, Credentials $credentials)
@@ -61,7 +61,7 @@ class TextToSpeechManager extends Manager
6161 /**
6262 * Get credentials of AWS.
6363 *
64 * @param array $credentials
64 * @param array $credentials
6565 * @return \Aws\Credentials\Credentials
6666 */
6767 protected function getCredentials(array $credentials)
src/Traits/HasLanguage.phpmodifiedformatting only+1-1
Changes to src/Traits/HasLanguage.php
@@ -12,7 +12,7 @@ trait HasLanguage
1212 /**
1313 * Sets the language to be used.
1414 *
15 * @param string $language
15 * @param string $language
1616 * @return $this
1717 */
1818 public function language(string $language)
src/Traits/HasSpeechMarks.phpmodifiedformatting only+1-1
Changes to src/Traits/HasSpeechMarks.php
@@ -12,7 +12,7 @@ trait HasSpeechMarks
1212 /**
1313 * Sets the speech mark types.
1414 *
15 * @param array $speechMarks
15 * @param array $speechMarks
1616 * @return $this
1717 */
1818 public function speechMarks(array $speechMarks)
src/Traits/Sourceable.phpmodified+3-2
formatting only · 8 hidden lines
Changes to src/Traits/Sourceable.php
@@ -16,7 +16,7 @@ trait Sourceable formatting only
1616 /**
1717 * Sets the source.
1818 *
19 * @param string $source
19 * @param string $source
2020 * @return $this
2121 */
2222 public function source(string $source)
Changes to src/Traits/Sourceable.php
@@ -28,7 +28,8 @@ trait Sourceable
2828
2929 /**
3030 * Get text from source.
31 * @param string $data
31 *
32 * @param string $data
3233 * @return string
3334 */
3435 protected function getTextFromSource(string $data): string
src/Traits/Storable.phpmodified+9-14
Changes to src/Traits/Storable.php
@@ -24,8 +24,7 @@ trait Storable
2424 /**
2525 * Set where to store the converted file.
2626 *
27 * @param string $disk
28 *
27 * @param string $disk
2928 * @return $this
3029 */
3130 public function disk(string $disk)
@@ -38,8 +37,7 @@ trait Storable
3837 /**
3938 * Set path to where to store the converted file.
4039 *
41 * @param string $path
42 *
40 * @param string $path
4341 * @return $this
4442 */
4543 public function saveTo(string $path)
@@ -52,9 +50,8 @@ trait Storable
5250 /**
5351 * Execute the store.
5452 *
55 * @param string $text
56 * @param mixed $resultContent
57 *
53 * @param string $text
54 * @param mixed $resultContent
5855 * @return string
5956 */
6057 protected function store($text, $resultContent)
@@ -63,7 +60,7 @@ trait Storable
6360
6461 $storage = Storage::disk($this->disk ?: config('tts.disk'));
6562
66 $storage->put($this->path, $resultContent);
63 $storage->put($this->path, $resultContent ?? '');
6764
6865 return $this->path;
6966 }
@@ -71,9 +68,8 @@ trait Storable
7168 /**
7269 * Ensures the path not to be null if it is null it will set a default path.
7370 *
74 * @param string $text
75 * @param mixed $audio
76 *
71 * @param string $text
72 * @param mixed $audio
7773 * @return void
7874 */
7975 protected function ensurePathIsNotNull($text, $audio)
@@ -111,9 +107,8 @@ trait Storable
111107 /**
112108 * Get default filename returned in Filename Formatter.
113109 *
114 * @param string $text
115 * @param mixed $audio
116 *
110 * @param string $text
111 * @param mixed $audio
117112 * @return string
118113 */
119114 protected function getDefaultFilename($text, $audio)