Passed
Push — master ( 909da3...6758a4 )
by Gino
02:16
created

GetApiInstancesTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 56
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTranslateApi() 0 3 1
A getDictionaryApi() 0 3 1
A getSpellCheckApi() 0 3 1
A getTtsApi() 0 3 1
1
<?php
2
3
namespace GinoPane\PHPolyglot\Supplemental;
4
5
use GinoPane\PHPolyglot\API\Factory\TTS\TtsApiFactory;
6
use GinoPane\PHPolyglot\API\Implementation\TTS\TtsApiInterface;
7
use GinoPane\PHPolyglot\API\Factory\Translate\TranslateApiFactory;
8
use GinoPane\PHPolyglot\API\Factory\Dictionary\DictionaryApiFactory;
9
use GinoPane\PHPolyglot\API\Factory\SpellCheck\SpellCheckApiFactory;
10
use GinoPane\PHPolyglot\API\Implementation\Translate\TranslateApiInterface;
11
use GinoPane\PHPolyglot\API\Implementation\Dictionary\DictionaryApiInterface;
12
use GinoPane\PHPolyglot\API\Implementation\SpellCheck\SpellCheckApiInterface;
13
14
/**
15
 * Trait GetApiInstancesTrait
16
 *
17
 * @author Sergey <Gino Pane> Karavay
18
 */
19
trait GetApiInstancesTrait
20
{
21
    /**
22
     * @codeCoverageIgnore
23
     *
24
     * Get Translate API instance
25
     *
26
     * @param array $parameters
27
     *
28
     * @return TranslateApiInterface
29
     */
30
    protected function getTranslateApi(array $parameters = []): TranslateApiInterface
31
    {
32
        return (new TranslateApiFactory())->getApi($parameters);
33
    }
34
35
    /**
36
     * @codeCoverageIgnore
37
     *
38
     * Get Dictionary API instance
39
     *
40
     * @param array $parameters
41
     *
42
     * @return DictionaryApiInterface
43
     */
44
    protected function getDictionaryApi(array $parameters = []): DictionaryApiInterface
45
    {
46
        return (new DictionaryApiFactory())->getApi($parameters);
47
    }
48
49
    /**
50
     * @codeCoverageIgnore
51
     *
52
     * Get Tts API instance
53
     *
54
     * @param array $parameters
55
     *
56
     * @return TtsApiInterface
57
     */
58
    protected function getTtsApi(array $parameters = []): TtsApiInterface
59
    {
60
        return (new TtsApiFactory())->getApi($parameters);
61
    }
62
63
    /**
64
     * @codeCoverageIgnore
65
     *
66
     * Get SpellCheck API instance
67
     *
68
     * @param array $parameters
69
     *
70
     * @return SpellCheckApiInterface
71
     */
72
    protected function getSpellCheckApi(array $parameters = []): SpellCheckApiInterface
73
    {
74
        return (new SpellCheckApiFactory())->getApi($parameters);
75
    }
76
}