Completed
Push — develop ( 213046...ebc20b )
by Barry
01:37
created

State::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Barryvanveen\CCA;
4
5
class State
6
{
7
    /** @var array */
8
    protected $array;
9
10
    /** @var string */
11
    protected $string;
12
    
13 9
    public function __construct(Grid $grid)
14
    {
15 9
        $this->array = $grid->toArray();
16
17 9
        $this->string = $grid->__toString();
18 9
    }
19
20 3
    public function toArray(): array
21
    {
22 3
        return $this->array;
23
    }
24
25 3
    public function toHash(): string
26
    {
27 3
        return hash('crc32', $this->string);
28
    }
29
30 3
    public function __toString()
31
    {
32 3
        return $this->string;
33
    }
34
}
35