NewsClientCommandTrait::getNewsClient()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace Stp\SndApi\News\Command;
4
5
use Stp\SndApi\News\Client;
6
use Symfony\Component\Console\Input\InputInterface;
7
8
trait NewsClientCommandTrait
9
{
10
    private $newsClient;
11
12
    private function initNewsClient(InputInterface $input)
13
    {
14
        $key = $input->getOption('key');
15
        $secret = $input->getOption('secret');
16
        $publicationId = $input->getOption('publicationId');
17
18
        $this->newsClient = new Client($key, $secret, $publicationId);
19
    }
20
21
    /**
22
     * @return Client
23
     */
24
    public function getNewsClient(InputInterface $input)
25
    {
26
        if (empty($this->newsClient)) {
27
            $this->initNewsClient($input);
28
        }
29
30
        return $this->newsClient;
31
    }
32
33
    /**
34
     * @param Client $newsClient
35
     */
36
    public function setNewsClient(Client $newsClient)
37
    {
38
        $this->newsClient = $newsClient;
39
    }
40
}
41