Completed
Push — master ( c19560...be122b )
by Rigel Kent
01:17
created

Sourceable::getTextFromWebsite()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Cion\TextToSpeech\Traits;
4
5
use Cion\TextToSpeech\Contracts\Source;
6
7
trait Sourceable
8
{
9
    /**
10
     * Determines where the text to convert from.
11
     *
12
     * @var string
13
     */
14
    protected $source;
15
16
    /**
17
     * Sets the source.
18
     *
19
     * @param string $source
20
     * @return $this
21
     */
22
    public function source(string $source)
23
    {
24
        $this->source = $source;
25
26
        return $this;
27
    }
28
29
    /**
30
     * Get text from source.
31
     * @param string $data
32
     * @return string
33
     */
34
    protected function getTextFromSource(string $data): string
35
    {
36
        if ($this->source !== null)
37
        {
38
            app()->bind(Source::class, config('tts.sources.' . $this->source));
39
        }
40
41
        return app(Source::class)->handle($data);
42
    }
43
}
44