Context   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 10
c 2
b 1
f 0
dl 0
loc 39
rs 10
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A setParameters() 0 3 1
A setOptions() 0 7 2
A getParameters() 0 3 1
A getOptions() 0 3 1
A getContext() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GusApi\Context;
6
7
final class Context implements ContextInterface
8
{
9
    /**
10
     * @var resource
11
     */
12
    private $context;
13
14
    public function __construct()
15
    {
16
        $this->context = stream_context_create();
17
    }
18
19
    public function setOptions(array $options): bool
20
    {
21
        if (function_exists('stream_context_set_options')) {
22
            return stream_context_set_options($this->context, $options);
23
        }
24
25
        return stream_context_set_option($this->context, $options);
26
    }
27
28
    public function setParameters(array $parameters): bool
29
    {
30
        return stream_context_set_params($this->context, $parameters);
31
    }
32
33
    public function getOptions(): array
34
    {
35
        return stream_context_get_options($this->context);
36
    }
37
38
    public function getParameters(): array
39
    {
40
        return stream_context_get_params($this->context);
41
    }
42
43
    public function getContext()
44
    {
45
        return $this->context;
46
    }
47
}
48