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

GitParseRevision   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
c 0
b 0
f 0
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromStringForRepository() 0 7 1
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