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.

LoadSongsCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 13 1
A execute() 0 19 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: wechsler
5
 * Date: 11/02/2017
6
 * Time: 20:19
7
 */
8
9
namespace Phase\TakeATicketBundle\Command;
10
11
use Phase\TakeATicket\SongLoader;
12
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
13
use Symfony\Component\Console\Input\InputArgument;
14
use Symfony\Component\Console\Input\InputInterface;
15
use Symfony\Component\Console\Output\OutputInterface;
16
17
class LoadSongsCommand extends ContainerAwareCommand
18
{
19
    protected function configure()
20
    {
21
        $this
22
            // the name of the command (the part after "bin/console")
23
            ->setName('ticket:load-songs')
24
            // the short description shown while running "php bin/console list"
25
            ->setDescription('Load songlist')
26
            // the full command description shown when running the command with
27
            // the "--help" option
28
            ->setHelp("Load songlist from XLS file")
29
            ->addArgument('file', InputArgument::REQUIRED, 'Name of the CSV file.')
30
            ->addArgument('mapper', InputArgument::OPTIONAL, 'ShortName of mapper to use', 'rclrockband');
31
    }
32
33
    protected function execute(InputInterface $input, OutputInterface $output)
34
    {
35
        $rowMapperManager = $this->getContainer()->get('songloader.rowmappermanager');
36
        /** @var  SongLoader\RowMapperManager $rowMapperManager */
37
        $mapper = $input->getArgument('mapper');
38
        $mapperClass = $rowMapperManager->getRowMapperClassByShortName($mapper);
39
40
        if (!$mapperClass) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $mapperClass of type string|null is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
41
            throw new \InvalidArgumentException("'$mapper' is not a valid mapper name");
42
        }
43
44
        $loader = new SongLoader();
45
        $loader->setRowMapperClass($mapperClass);
46
47
        $file = $input->getArgument('file');
48
        $songsLoaded = $loader->run($file, $this->getContainer()->get('database_connection'));
49
        $output->writeln("");
50
        $output->writeln("Loaded $songsLoaded songs from $file");
51
    }
52
}
53