SubversionChangesCountProcess::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Churn\Process\ChangesCount;
6
7
use Churn\File\File;
8
use Churn\Process\ChangesCountInterface;
9
use Churn\Process\ChurnProcess;
10
use Symfony\Component\Process\Process;
11
12
/**
13
 * @internal
14
 */
15
final class SubversionChangesCountProcess extends ChurnProcess implements ChangesCountInterface
16
{
17
    /**
18
     * Class constructor.
19
     *
20
     * @param File $file The file the process is being executed on.
21
     * @param string $dateRange String containing a date range formatted for SVN.
22
     */
23
    public function __construct(File $file, string $dateRange)
24
    {
25
        $process = new Process(['svn', 'log', '-q', '-r', $dateRange, $file->getFullPath()]);
26
27
        parent::__construct($file, $process);
28
    }
29
30
    /**
31
     * Returns the number of changes for a file.
32
     */
33
    #[\Override]
34
    public function countChanges(): int
35
    {
36
        return (int) \floor(\substr_count($this->getOutput(), "\n") / 2);
37
    }
38
}
39