Passed
Push — master ( a08302...5e3dfd )
by Jhao
02:06
created

GenericRequest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 3 1
A toArray() 0 3 1
A __construct() 0 7 2
1
<?php
2
3
/**
4
 * This file is part of RussianPost SDK package.
5
 *
6
 * © Appwilio (http://appwilio.com), greabock (https://github.com/greabock), JhaoDa (https://github.com/jhaoda)
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Appwilio\RussianPostSDK\Core;
15
16
final class GenericRequest implements Arrayable
17
{
18
    private $data;
19
20 6
    public static function create(iterable $data): self
21
    {
22 6
        return new self($data);
23
    }
24
25 6
    public function __construct(iterable $data)
26
    {
27 6
        if ($data instanceof \Traversable) {
28 1
            $data = \iterator_to_array($data);
29
        }
30
31 6
        $this->data = $data;
32 6
    }
33
34 5
    public function toArray(): array
35
    {
36 5
        return $this->data;
37
    }
38
}
39