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

GenericRequest::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
cc 2
nc 2
nop 1
crap 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