Passed
Push — master ( dc02eb...49fb01 )
by Tom
04:07
created

Composer   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 22
ccs 10
cts 10
cp 1
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A which() 0 3 1
A whichPhp() 0 9 4
1
<?php
2
3
/* this file is part of pipelines */
4
5
namespace Ktomk\Pipelines;
6
7
use Symfony\Component\Process\PhpExecutableFinder;
8
9
/**
10
 * Composer "which" script host
11
 *
12
 * Utility class to provide composer script bindings directly
13
 * in PHP.
14
 *
15
 * the original "echo ${COMPOSER_BINARY}" was not portable
16
 * for composer 2 < 2.0.7.
17
 *
18
 * @package Ktomk\Pipelines
19
 */
20
class Composer
21
{
22
    /**
23
     * composer which script
24
     */
25 1
    public static function which()
26
    {
27 1
        echo realpath($_SERVER['argv'][0]), "\n";
28 1
    }
29
30
    /**
31
     * @see composer/composer: \Composer\EventDispatcher\EventDispatcher::doDispatch
32
     */
33 1
    public static function whichPhp()
34
    {
35 1
        $phpPath = null;
36 1
        if (class_exists('Symfony\Component\Process\PhpExecutableFinder')) {
37 1
            $finder = new PhpExecutableFinder();
38 1
            $phpPath = $finder->find(false);
39
        }
40 1
        isset($phpPath) || (defined('PHP_BINARY') && $phpPath = constant('PHP_BINARY'));
41 1
        echo $phpPath, "\n";
0 ignored issues
show
Bug introduced by
Are you sure $phpPath of type false|null|string can be used in echo? ( Ignorable by Annotation )

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

41
        echo /** @scrutinizer ignore-type */ $phpPath, "\n";
Loading history...
42 1
    }
43
}
44