Browser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A viewURI() 0 7 1
1
<?php
2
namespace Nubs\Sensible;
3
4
use Symfony\Component\Process\ProcessBuilder;
5
6
/**
7
 * Wraps the browser to execute it.
8
 */
9
class Browser
10
{
11
    /** @type string The browser command to use. */
12
    private $_browserCommand;
13
14
    /**
15
     * Initialize the browser command.
16
     *
17
     * @api
18
     * @param string $browserCommand The browser command to use.
19
     */
20
    public function __construct($browserCommand)
21
    {
22
        $this->_browserCommand = $browserCommand;
23
    }
24
25
    /**
26
     * View the given URI using the symfony process builder to build the symfony
27
     * process to execute.
28
     *
29
     * @api
30
     * @param \Symfony\Component\Process\ProcessBuilder $processBuilder The
31
     *     process builder.
32
     * @param string $uri The URI to view.
33
     * @return \Symfony\Component\Process\Process The already-executed process.
34
     */
35
    public function viewURI(ProcessBuilder $processBuilder, $uri)
36
    {
37
        $proc = $processBuilder->setPrefix($this->_browserCommand)->setArguments([$uri])->getProcess();
38
        $proc->setTty(true)->run();
39
40
        return $proc;
41
    }
42
}
43