Passed
Push — main ( 189a60...255c0f )
by Yevhenii
02:11
created

Options   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
eloc 16
c 0
b 0
f 0
dl 0
loc 84
ccs 0
cts 19
cp 0
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setUserAgent() 0 5 1
A getProxy() 0 3 1
A getTimeout() 0 3 1
A getUserAgent() 0 3 1
A setProxy() 0 5 1
A setFromOptions() 0 5 1
A setTimeout() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SteamMarketProviders\ParserManager\Http;
6
7
class Options
8
{
9
    /**
10
     * @var string|null
11
     */
12
    private null|string $userAgent;
13
14
    /**
15
     * @var int
16
     */
17
    private int $timeout;
18
19
    /**
20
     * @var string|null
21
     */
22
    private null|string $proxy;
23
24
    /**
25
     * @param string $userAgent
26
     * @return $this
27
     */
28
    public function setUserAgent(string $userAgent): Options
29
    {
30
        $this->userAgent = $userAgent;
31
32
        return $this;
33
    }
34
35
    /**
36
     * @return string|null
37
     */
38
    public function getUserAgent(): null|string
39
    {
40
        return $this->userAgent;
41
    }
42
43
    /**
44
     * @param int $timeout
45
     * @return $this
46
     */
47
    public function setTimeout(int $timeout): Options
48
    {
49
        $this->timeout = $timeout;
50
51
        return $this;
52
    }
53
54
    /**
55
     * @return int
56
     */
57
    public function getTimeout(): int
58
    {
59
        return $this->timeout;
60
    }
61
62
    /**
63
     * @param string $proxy
64
     * @return $this
65
     */
66
    public function setProxy(string $proxy): Options
67
    {
68
        $this->proxy = $proxy;
69
70
        return $this;
71
    }
72
73
    /**
74
     * @return string
75
     */
76
    public function getProxy(): string
77
    {
78
        return $this->proxy;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->proxy could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
79
    }
80
81
82
    /**
83
     * @param Options $options
84
     * @return $this
85
     */
86
    public function setFromOptions(Options $options): Options
87
    {
88
        return $this->setUserAgent($options->getUserAgent())
0 ignored issues
show
Bug introduced by
It seems like $options->getUserAgent() can also be of type null; however, parameter $userAgent of SteamMarketProviders\Par...Options::setUserAgent() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

88
        return $this->setUserAgent(/** @scrutinizer ignore-type */ $options->getUserAgent())
Loading history...
89
            ->setTimeout($options->getTimeout())
90
            ->setProxy($options->getProxy());
91
    }
92
}
93