Passed
Pull Request — master (#50)
by Marco
02:46
created

GitParseRevision::fromStringForRepository()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 2
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Roave\BackwardCompatibility\Git;
6
7
use Symfony\Component\Process\Exception\RuntimeException;
8
use Symfony\Component\Process\Process;
9
10
final class GitParseRevision implements ParseRevision
11
{
12
    /**
13
     * {@inheritDoc}
14
     * @throws RuntimeException
15
     */
16
    public function fromStringForRepository(string $something, CheckedOutRepository $repository) : Revision
17
    {
18
        return Revision::fromSha1(
19
            (new Process(['git', 'rev-parse', $something]))
20
                ->setWorkingDirectory((string) $repository)
21
                ->mustRun()
22
                ->getOutput()
23
        );
24
    }
25
}
26