-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from bmitch/bmitchell-42
Fixes #42
- Loading branch information
Showing
10 changed files
with
212 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
|
||
namespace Churn\Values; | ||
|
||
class Config | ||
{ | ||
/** | ||
* The number of files to display in the results table. | ||
* @var integer | ||
*/ | ||
private $filesToShow; | ||
|
||
/** | ||
* The number of parallel jobs to use to process the files. | ||
* @var integer | ||
*/ | ||
private $parallelJobs; | ||
|
||
/** | ||
* How far back in the git history to go to count commits. | ||
* @var string | ||
*/ | ||
private $commitsSince; | ||
|
||
/** | ||
* The paths to files to ignore when processing. | ||
* @var array | ||
*/ | ||
private $filesToIgnore; | ||
|
||
/** | ||
* Config constructor. | ||
* @param array $rawData Raw config data. | ||
*/ | ||
public function __construct(array $rawData = []) | ||
{ | ||
$this->filesToShow = $rawData['filesToShow'] ?? 10; | ||
$this->parallelJobs = $rawData['parallelJobs'] ?? 10; | ||
$this->commitsSince = $rawData['commitsSince'] ?? '10 years ago'; | ||
$this->filesToIgnore = $rawData['filesToIgnore'] ?? []; | ||
} | ||
|
||
/** | ||
* Get the number of files to display in the results table. | ||
* @return integer | ||
*/ | ||
public function getFilesToShow(): int | ||
{ | ||
return $this->filesToShow; | ||
} | ||
|
||
/** | ||
* Get the number of parallel jobs to use to process the files. | ||
* @return integer | ||
*/ | ||
public function getParallelJobs(): int | ||
{ | ||
return $this->parallelJobs; | ||
} | ||
|
||
/** | ||
* Get how far back in the git history to go to count commits. | ||
* @return string | ||
*/ | ||
public function getCommitsSince(): string | ||
{ | ||
return $this->commitsSince; | ||
} | ||
|
||
/** | ||
* Get the paths to files to ignore when processing. | ||
* @return array | ||
*/ | ||
public function getFilesToIgnore(): array | ||
{ | ||
return $this->filesToIgnore; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
|
||
namespace Churn\Tests\Unit\Values; | ||
|
||
|
||
use Churn\Tests\BaseTestCase; | ||
use Churn\Values\Config; | ||
|
||
class ConfigTest extends BaseTestCase | ||
{ | ||
/** @test **/ | ||
public function it_can_be_instantiated() | ||
{ | ||
$this->assertInstanceOf(Config::class, new Config([])); | ||
} | ||
|
||
/** @test **/ | ||
public function it_can_be_instantiated_without_any_parameters() | ||
{ | ||
$this->assertInstanceOf(Config::class, new Config); | ||
} | ||
|
||
/** @test **/ | ||
public function it_can_return_its_default_values_when_instantiated_without_any_parameters() | ||
{ | ||
$config = new Config; | ||
$this->assertSame(10, $config->getFilesToShow()); | ||
$this->assertSame(10, $config->getParallelJobs()); | ||
$this->assertSame('10 years ago', $config->getCommitsSince()); | ||
$this->assertSame([], $config->getFilesToIgnore()); | ||
} | ||
|
||
/** @test **/ | ||
public function it_can_return_its_values_when_instantiated_parameters() | ||
{ | ||
$config = new Config([ | ||
'filesToShow' => 13, | ||
'parallelJobs' => 7, | ||
'commitsSince' => '4 years ago', | ||
'filesToIgnore' => ['foo.php', 'bar.php', 'baz.php'] | ||
]); | ||
$this->assertSame(13, $config->getFilesToShow()); | ||
$this->assertSame(7, $config->getParallelJobs()); | ||
$this->assertSame('4 years ago', $config->getCommitsSince()); | ||
$this->assertSame(['foo.php', 'bar.php', 'baz.php'], $config->getFilesToIgnore()); | ||
} | ||
|
||
} |