ProcessFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 4
c 3
b 0
f 2
lcom 1
cbo 1
dl 0
loc 30
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A make() 0 8 3
1
<?php
2
/**
3
 * File ProcessFactory.php
4
 *
5
 * @author Edward Pfremmer <[email protected]>
6
 */
7
namespace Epfremme\ProcessQueue\Process;
8
9
use Symfony\Component\Process\Process;
10
11
/**
12
 * Class ProcessFactory
13
 *
14
 * @package Epfremme\ProcessQueue\Process
15
 */
16
class ProcessFactory
17
{
18
    /**
19
     * @var string
20
     */
21
    private $cmd;
22
23
    /**
24
     * ProcessFactory constructor
25
     *
26
     * @param string $cmd
27
     */
28 11
    public function __construct($cmd)
29
    {
30 11
        $this->cmd = $cmd;
31 11
    }
32
33
    /**
34
     * @param \SplFileInfo|string $cwd
35
     * @return Process
36
     */
37 8
    public function make($cwd = null)
38
    {
39 8
        if (!is_null($cwd) && !is_dir($cwd)) {
40 1
            throw new Exception\InvalidWorkingDirectoryException($cwd);
41
        }
42
43 7
        return new Process($this->cmd, $cwd);
0 ignored issues
show
Bug introduced by
It seems like $cwd defined by parameter $cwd on line 37 can also be of type object<SplFileInfo>; however, Symfony\Component\Process\Process::__construct() does only seem to accept string|null, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and 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...
44
    }
45
}
46