Test Failed
Branch php7.0-lt7.0.8 (2e7dc7)
by SignpostMarv
05:18
created

Command::getDefaultName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
* @author SignpostMarv
4
*/
5
declare(strict_types=1);
6
7
namespace SignpostMarv\DaftFramework\Symfony\Console\Command;
8
9
use SignpostMarv\DaftFramework\AttachDaftFramework;
10
use Symfony\Component\Console\Command\Command as Base;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
abstract class Command extends Base
14
{
15
    use AttachDaftFramework;
16
17
    /**
18
    * @var string
19
    */
20
    protected static $defaultName = '';
21
22
    public static function getDefaultName() : string
23
    {
24
        if (method_exists(Base::class, 'getDefaultName')) {
25
            return (string) parent::getDefaultName();
0 ignored issues
show
Bug introduced by
The method getDefaultName() does not exist on Symfony\Component\Console\Command\Command. It seems like you code against a sub-type of Symfony\Component\Console\Command\Command such as SignpostMarv\DaftFramewo...Console\Command\Command. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
            return (string) parent::/** @scrutinizer ignore-call */ getDefaultName();
Loading history...
26
        }
27
28
        return static::$defaultName;
29
    }
30
31
    protected static function tempnam() : string
32
    {
33
        return (string) realpath((string) tempnam(sys_get_temp_dir(), static::class));
34
    }
35
36
    /**
37
    * @return string|null
38
    */
39
    final protected static function tempnamCheck(OutputInterface $output)
40
    {
41
        $tempnam = static::tempnam();
42
43
        if ( ! is_dir($tempnam) && is_file($tempnam) && is_writable($tempnam)) {
44
            return $tempnam;
45
        }
46
47
        $output->writeln('could not get temporary filename!');
48
    }
49
}
50