Locale   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 18 4
1
<?php
2
// Copyright 1999-2021. Plesk International GmbH.
3
4
namespace PleskX\Api\Operator;
5
6
use PleskX\Api\Struct\Locale as Struct;
7
8
class Locale extends \PleskX\Api\Operator
9
{
10
    /**
11
     * @param string|null $id
12
     *
13
     * @return Struct\Info|Struct\Info[]
14
     */
15
    public function get($id = null)
16
    {
17
        $locales = [];
18
        $packet = $this->_client->getPacket();
19
        $filter = $packet->addChild($this->_wrapperTag)->addChild('get')->addChild('filter');
20
21
        if (!is_null($id)) {
22
            $filter->addChild('id', $id);
23
        }
24
25
        $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
26
27
        foreach ($response->locale->get->result as $localeInfo) {
28
            $locales[(string) $localeInfo->info->id] = new Struct\Info($localeInfo->info);
29
        }
30
31
        return !is_null($id) ? reset($locales) : $locales;
32
    }
33
}
34