TtsApiFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 51
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getApi() 0 3 1
A getTargetDirectory() 0 7 1
1
<?php
2
3
namespace GinoPane\PHPolyglot\API\Factory\TTS;
4
5
use GinoPane\PHPolyglot\API\Factory\ApiFactoryAbstract;
6
use GinoPane\PHPolyglot\Exception\InvalidPathException;
7
use GinoPane\PHPolyglot\API\Implementation\TTS\TtsApiInterface;
8
9
class TtsApiFactory extends ApiFactoryAbstract
10
{
11
    /**
12
     * Config section name that is being checked for existence. API-specific properties must
13
     * be located under that section
14
     *
15
     * @var string
16
     */
17
    protected $configSectionName = 'ttsApi';
18
19
    /**
20
     * API interface that must be implemented by API class
21
     *
22
     * @var string
23
     */
24
    protected $apiInterface = TtsApiInterface::class;
25
26
    /**
27
     * Config properties that must exist for valid config
28
     *
29
     * @var array
30
     */
31
    protected $configProperties = [
32
        'default',
33
        'directory'
34
    ];
35
36
    /**
37
     * Gets necessary Dictionary API object
38
     *
39
     * @param array $parameters
40
     *
41
     * @return TtsApiInterface
42
     */
43
    public function getApi(array $parameters = []): TtsApiInterface
44
    {
45
        return parent::getApi($parameters);
46
    }
47
48
    /**
49
     * @return string
50
     *
51
     * @throws InvalidPathException
52
     */
53
    public function getTargetDirectory(): string
54
    {
55
        $directoryName = $this->getRootRelatedPath($this->getFactorySpecificConfig()['directory']);
56
57
        $this->assertDirectoryIsWriteable($directoryName);
58
59
        return $directoryName;
60
    }
61
}
62