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
04:35
created

CreateWorkspace   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 15 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getWorkspaceDirectories() 0 10 1
A handle() 6 18 3

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 CreateWorkspace extends DefaultStep
9
{
10
    /**
11
     * Return the directories that should be created.
12
     *
13
     * @return array
14
     */
15
    public function getWorkspaceDirectories()
16
    {
17
        return [
18
            'workspace'     => WORKSPACE,
19
            'data-sources'  => DATASOURCES,
20
            'events'        => EVENTS,
21
            'pages'         => PAGES,
22
            'utilities'     => UTILITIES
23
        ];
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function handle(Configuration $config, array $data)
30
    {
31
        foreach ($this->getWorkspaceDirectories() as $name => $dir) {
32
            $this->logger->info(sprintf(
33
                'WRITING: Creating ‘%s‘ folder',
34
                $name
35
            ));
36
37 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...
38
                throw new Exception(sprintf(
39
                    'Could not create ‘%s’ directory. Check permission on the root folder.',
40
                    $name
41
                ));
42
            }
43
        }
44
45
        return true;
46
    }
47
}
48