DynamicStub   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 34
ccs 0
cts 15
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A compileInitialization() 0 10 1
1
<?php
2
/**
3
 * For licensing information, please see the LICENSE file accompanied with this file.
4
 *
5
 * @author Gerard van Helden <[email protected]>
6
 * @copyright 2012 Gerard van Helden <http://melp.nl>
7
 */
8
namespace Zicht\Tool\Packager\Node;
9
10
use Zicht\Tool\Script\Buffer;
11
12
/**
13
 * PHAR stub for a dynamic Z build
14
 */
15
class DynamicStub extends Stub
16
{
17
    /**
18
     * Construct the stub with the specified details
19
     *
20
     * @param \Phar $phar
21
     * @param string $appName
22
     * @param string $appVersion
23
     * @param string $configFileName
24
     */
25
    public function __construct(\Phar $phar, $appName, $appVersion, $configFileName)
26
    {
27
        parent::__construct($phar, $appName, $appVersion);
28
        $this->configFilename = $configFileName;
0 ignored issues
show
Bug introduced by
The property configFilename does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
29
    }
30
31
32
    /**
33
     * Writes the initialization code for a dynamic build
34
     *
35
     * @param \Zicht\Tool\Script\Buffer $buffer
36
     * @return void
37
     */
38
    protected function compileInitialization(Buffer $buffer)
39
    {
40
        $buffer->write('$app = new Zicht\Tool\Application(')
41
            ->asPhp($this->appName)
42
            ->raw(', Zicht\Version\Version::fromString(')
43
            ->asPhp($this->appVersion)
44
            ->raw(') ?: new Zicht\Version\Version(), Zicht\Tool\Configuration\ConfigurationLoader::fromEnv(')->asPhp($this->configFilename)->raw(')')
45
            ->raw(');')
46
            ->eol();
47
    }
48
}
49