Passed
Push — master ( 956163...dedbc7 )
by Christian
03:02
created

BasicAuth   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A generate() 0 6 1
1
<?php declare(strict_types=1);
2
3
namespace Cocotte\Shell;
4
5
use Symfony\Component\Process\Process;
6
7
final class BasicAuth
8
{
9
    /**
10
     * @var ProcessRunner
11
     */
12
    private $processRunner;
13
14
    public function __construct(ProcessRunner $processRunner)
15
    {
16
        $this->processRunner = $processRunner;
17
    }
18
19
    public function generate(string $username, string $password): string
20
    {
21
        $process = new Process(['htpasswd', '-b', '-n', $username, $password]);
22
        $this->processRunner->mustRun($process);
23
24
        return trim($process->getOutput());
25
    }
26
27
}