Decode   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 0
loc 26
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 11 1
A execute() 0 11 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