HasApiTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 7
dl 0
loc 30
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A initApi() 0 3 1
A generateApi() 0 3 1
A getApi() 0 6 2
1
<?php
2
3
namespace Paytic\Omnipay\Paylike\Traits;
4
5
/**
6
 * Trait HasApiTrait
7
 * @package Paytic\Omnipay\Paylike\Traits
8
 *
9
 * @method string getPrivateKey
10
 */
11
trait HasApiTrait
12
{
13
    /**
14
     * @var null|\Paylike\Paylike
15
     */
16
    protected $api = null;
17
18
    /**
19
     * @return \Paylike\Paylike
20
     */
21
    public function getApi()
22
    {
23
        if ($this->api == null) {
24
            $this->initApi();
25
        }
26
        return $this->api;
27
    }
28
29
    protected function initApi()
30
    {
31
        $this->api = $this->generateApi();
32
    }
33
34
    /**
35
     * @return \Paylike\Paylike
36
     * @throws \Paylike\Exception\ApiException
37
     */
38
    protected function generateApi()
39
    {
40
        return new \Paylike\Paylike($this->getPrivateKey());
41
    }
42
}
43