ServerStorage   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 30
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getFilepath() 0 4 1
A saveContents() 0 6 2
1
<?php
2
3
/*
4
 * This file is part of Rocketeer
5
 *
6
 * (c) Maxime Fabre <[email protected]>
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
13
namespace Rocketeer\Services\Storages;
14
15
use Rocketeer\Services\Container\Container;
16
17
/**
18
 * Stores information about the current state of the application
19
 * on a specific server.
20
 */
21
class ServerStorage extends Storage
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26 121
    public function __construct(Container $container)
27
    {
28 121
        $this->container = $container;
29
30 121
        parent::__construct($container, 'remote', $this->paths->getFolder(), 'state');
0 ignored issues
show
Documentation Bug introduced by Maxime Fabre
The method getFolder does not exist on object<Rocketeer\Services\Environment\Pathfinder>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
31 121
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36 119
    public function getFilepath()
37
    {
38 119
        return $this->paths->getFolder().DS.$this->getFilename();
0 ignored issues
show
Documentation Bug introduced by Maxime Fabre
The method getFolder does not exist on object<Rocketeer\Services\Environment\Pathfinder>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 25
    protected function saveContents($contents)
45
    {
46 25
        if (!$this->getOption('pretend')) {
47 5
            parent::saveContents($contents);
48 5
        }
49 25
    }
50
}
51