MercurialChangesCountProcess   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 1
b 0
f 0
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A countChanges() 0 4 1
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 MercurialChangesCountProcess 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 $dateSince String containing the date of when to look at commits since (Y-m-d).
22
     */
23
    public function __construct(File $file, string $dateSince)
24
    {
25
        $process = new Process([
26
            'hg', '--pager=never', '--color=never',
27
            'log', '--date', "$dateSince to now",
28
            $file->getFullPath(), '--template=\'1\\n\'',
29
        ], \dirname($file->getFullPath()));
30
31
        parent::__construct($file, $process);
32
    }
33
34
    /**
35
     * Returns the number of changes for a file.
36
     */
37
    #[\Override]
38
    public function countChanges(): int
39
    {
40
        return \substr_count($this->getOutput(), "\n");
41
    }
42
}
43