ClassFileWriter::write()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 8.8571
c 0
b 0
f 0
ccs 0
cts 7
cp 0
cc 1
eloc 10
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Brazanation\States\Console\Commands\Generate;
4
5
class ClassFileWriter
6
{
7
    public function write($path, GenericState $state)
8
    {
9
        $fileContent = <<<FILE
10
<?php
11
12
namespace Brazanation\States;
13
14
class {$state->getClassName()} extends State
15
{
16
    const CODE = {$state->getCode()};
17
18
    const FULL_NAME = '{$state->getFullName()}';
19
20
    const SHORT_NAME = '{$state->getShortName()}';
21
22
    const TIMEZONE = '{$state->getTimeZone()}';
23
24
    public function __construct()
25
    {
26
        parent::__construct(
27
            self::FULL_NAME,
28
            self::SHORT_NAME,
29
            self::CODE,
30
            self::TIMEZONE
31
        );
32
    }
33
}
34
35
FILE;
36
37
        return file_put_contents("{$path}/{$state->getClassName()}.php", $fileContent);
38
    }
39
}
40