Language   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 7
c 1
b 0
f 0
dl 0
loc 29
ccs 11
cts 11
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getToQuery() 0 7 3
A getLanguage() 0 3 1
A canAddLanguage() 0 3 2
A __construct() 0 4 1
1
<?php
2
3
namespace kalanis\google_maps\Remote\Headers;
4
5
6
use kalanis\google_maps\ClientConfig;
7
8
9
/**
10
 * Class for work with language params
11
 */
12
class Language
13
{
14 57
    public function __construct(
15
        protected readonly ClientConfig $config,
16
    )
17
    {
18 57
    }
19
20
    /**
21
     * @param string $method
22
     * @return array<string, string>
23
     */
24 35
    public function getToQuery(string $method): array
25
    {
26 35
        $params = [];
27 35
        if ($this->canAddLanguage($method) && !empty($this->config->getLanguage())) {
28 2
            $params['language'] = $this->config->getLanguage();
29
        }
30 35
        return $params;
31
    }
32
33 35
    protected function canAddLanguage(string $method): bool
34
    {
35 35
        return ('GET' == strtoupper($method)) && $this->config->getLanguage();
36
    }
37
38 4
    public function getLanguage(): ?string
39
    {
40 4
        return $this->config->getLanguage();
41
    }
42
}
43