Browser::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 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