Passed
Push — master ( 34beb8...79bf97 )
by Alberto
14:24 queued 13s
created

ApiClientTrait::getClient()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 7
rs 10
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * BEdita, API-first content management framework
6
 * Copyright 2023 Atlas Srl, Chialab Srl
7
 *
8
 * This file is part of BEdita: you can redistribute it and/or modify
9
 * it under the terms of the GNU Lesser General Public License as published
10
 * by the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * See LICENSE.LGPL or <http://gnu.org/licenses/lgpl-3.0.html> for more details.
14
 */
15
namespace App\Utility;
16
17
use BEdita\SDK\BEditaClient;
18
use BEdita\WebTools\ApiClientProvider;
19
20
/**
21
 * Read and write configuration via API
22
 */
23
trait ApiClientTrait
24
{
25
    /**
26
     * BEdita Api client
27
     *
28
     * @var \BEdita\SDK\BEditaClient|null
29
     */
30
    protected $apiClient = null;
31
32
    /**
33
     * Get API client.
34
     *
35
     * @return \BEdita\SDK\BEditaClient
36
     */
37
    public function getClient(): BEditaClient
38
    {
39
        if ($this->apiClient === null) {
40
            $this->apiClient = ApiClientProvider::getApiClient();
41
        }
42
43
        return $this->apiClient;
44
    }
45
}
46