NewsClientCommandTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 33
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A initNewsClient() 0 8 1
A getNewsClient() 0 8 2
A setNewsClient() 0 4 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