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

Composer::which()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
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