GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — integration (#2604)
by Brendan
05:28
created

CreateManifest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 10.53 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 6
loc 57
rs 10
wmc 6
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getManifestDirectories() 0 9 1
B handle() 6 36 5

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace SymphonyCms\Installer\Steps;
3
4
use Configuration;
5
use Exception;
6
use General;
7
8
class CreateManifest extends DefaultStep
9
{
10
    /**
11
     * Return the directories that should be created.
12
     *
13
     * @return array
14
     */
15
    public function getManifestDirectories()
16
    {
17
        return [
18
            'manifest' => MANIFEST,
19
            'logs'     => MANIFEST . '/logs',
20
            'cache'    => MANIFEST . '/cache',
21
            'tmp'      => MANIFEST . '/tmp'
22
        ];
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function handle(Configuration $config, array $data)
29
    {
30
        foreach ($this->getManifestDirectories() as $name => $dir) {
31
            if (is_dir($dir)) {
32
                if ($this->override) {
33
                    $this->logger->info(sprintf(
34
                        'REMOVING: Deleting ‘%s‘ folder',
35
                        $name
36
                    ));
37
38
                    General::deleteDirectory($dir);
39
                } else {
40
                    $this->logger->info(sprintf(
41
                        'SKIPPING: `%s` folder exists',
42
                        $name
43
                    ));
44
45
                    continue;
46
                }
47
            }
48
49
            $this->logger->info(sprintf(
50
                'WRITING: Creating ‘%s‘ folder',
51
                $name
52
            ));
53
54 View Code Duplication
            if (!General::realiseDirectory($dir, $config->get('write_mode', 'directory'))) {
0 ignored issues
show
Documentation introduced by
$config->get('write_mode', 'directory') is of type array|string, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
55
                throw new Exception(sprintf(
56
                    'Could not create ‘%s’ directory. Check permission on the root folder.',
57
                    $name
58
                ));
59
            }
60
        }
61
62
        return true;
63
    }
64
}
65