Decode::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.9
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the Geotools library.
5
 *
6
 * (c) Antoine Corcy <[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
namespace League\Geotools\CLI\Command\Geohash;
13
14
use League\Geotools\Geotools;
15
use Symfony\Component\Console\Input\InputArgument;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Output\OutputInterface;
18
19
/**
20
 * Command-line geohash:decode class
21
 *
22
 * @author Antoine Corcy <[email protected]>
23
 */
24
class Decode extends \Symfony\Component\Console\Command\Command
25
{
26 4
    protected function configure()
27
    {
28
        $this
29 4
            ->setName('geohash:decode')
30 4
            ->setDescription('Decode a geo hash string to a coordinate')
31 4
            ->addArgument('geohash', InputArgument::REQUIRED, 'The geo hash to decode to coordinate')
32 4
            ->setHelp(<<<EOT
33 4
<info>Example</info>:              %command.full_name% spey61y
34
EOT
35
            );
36 4
    }
37
38 3
    protected function execute(InputInterface $input, OutputInterface $output)
39
    {
40 3
        $geotools   = new Geotools;
41 3
        $coordinate = $geotools->geohash()->decode($input->getArgument('geohash'))->getCoordinate();
0 ignored issues
show
Bug introduced by
It seems like $input->getArgument('geohash') targeting Symfony\Component\Consol...nterface::getArgument() can also be of type array<integer,string> or null; however, League\Geotools\Geohash\GeohashInterface::decode() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
42
43 2
        $output->writeln(sprintf(
44 2
            '<value>%s, %s</value>',
45 2
            $coordinate->getLatitude(), $coordinate->getLongitude()
46
        ));
47 2
        return 0;
48
    }
49
}
50