GitParseRevision::fromStringForRepository()   A
last analyzed

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 10
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
     *
15
     * @throws RuntimeException
16
     */
17
    public function fromStringForRepository(string $something, CheckedOutRepository $repository) : Revision
18
    {
19
        return Revision::fromSha1(
20
            (new Process(['git', 'rev-parse', $something]))
21
                ->setWorkingDirectory($repository->__toString())
22
                ->mustRun()
23
                ->getOutput()
24
        );
25
    }
26
}
27