generated from yardinternet/skeleton-package
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfig.php
60 lines (44 loc) · 1.23 KB
/
Config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
namespace Yard\PhpCsFixerRules;
use PhpCsFixer\Finder;
use Yard\PhpCsFixerRules\Interfaces\ConfigInterface;
use Yard\PhpCsFixerRules\Traits\Helpers;
class Config extends \PhpCsFixer\Config implements ConfigInterface
{
use Helpers;
private function __construct(string $name)
{
parent::__construct($name);
}
public static function create(Finder $finder, string $name = 'default'): self
{
$config = new self($name);
$config->setFinder($finder);
$config->setDefaultRules();
return $config;
}
public function setDefaultRules(): self
{
$this->setRules($this->configRule('rules', []))
->setLineEnding($this->configRule('line_ending', "\n"))
->setRiskyAllowed($this->configRule('risky_allowed', true))
->setIndent($this->configRule('set_indent', "\t"));
return $this;
}
public function mergeRules(array $rules): self
{
$this->setRules(\Ckr\Util\ArrayMerger::doMerge($this->getRules(), $rules));
return $this;
}
public function removeRules(array $rulesKeys): self
{
$rules = $this->getRules();
$this->setRules(array_diff_key($rules, array_flip($rulesKeys)));
return $this;
}
public function removeRule(string $ruleKey): self
{
return $this->removeRules([$ruleKey]);
}
}