Sourceable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 3
Bugs 1 Features 1
Metric Value
eloc 7
c 3
b 1
f 1
dl 0
loc 34
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTextFromSource() 0 7 2
A source() 0 5 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
            app()->bind(Source::class, config('tts.sources.'.$this->source));
38
        }
39
40
        return app(Source::class)->handle($data);
41
    }
42
}
43