ArrayUtil.php
3 years ago
Config.php
3 years ago
ConfigCollection.php
3 years ago
ConfigCollectionFactory.php
3 years ago
ConfigCollectionInterface.php
3 years ago
ConfigFactory.php
3 years ago
ConfigInterface.php
3 years ago
Filesystem.php
3 years ago
FilesystemInterface.php
3 years ago
Imposter.php
3 years ago
ImposterFactory.php
3 years ago
ImposterInterface.php
3 years ago
ProjectConfig.php
3 years ago
ProjectConfigInterface.php
3 years ago
StringUtil.php
3 years ago
Transformer.php
3 years ago
TransformerInterface.php
3 years ago
ProjectConfig.php
62 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace TypistTech\Imposter; |
| 6 | |
| 7 | use UnexpectedValueException; |
| 8 | |
| 9 | class ProjectConfig extends Config implements ProjectConfigInterface |
| 10 | { |
| 11 | /** |
| 12 | * @var string[] |
| 13 | */ |
| 14 | protected const DEFAULT_EXCLUDES = ['typisttech/imposter']; |
| 15 | |
| 16 | /** |
| 17 | * @var string[] |
| 18 | */ |
| 19 | private $extraExcludes = []; |
| 20 | |
| 21 | /** |
| 22 | * @return string[] |
| 23 | */ |
| 24 | public function getExcludes(): array |
| 25 | { |
| 26 | $extra = $this->get('extra'); |
| 27 | $excludes = $extra['imposter']['excludes'] ?? []; |
| 28 | |
| 29 | return array_merge(static::DEFAULT_EXCLUDES, $excludes, $this->extraExcludes); |
| 30 | } |
| 31 | |
| 32 | public function getImposterNamespace(): string |
| 33 | { |
| 34 | $extra = $this->get('extra'); |
| 35 | |
| 36 | if (empty($extra['imposter']['namespace'])) { |
| 37 | throw new UnexpectedValueException('Imposter namespace is empty'); |
| 38 | } |
| 39 | |
| 40 | return $extra['imposter']['namespace']; |
| 41 | } |
| 42 | |
| 43 | public function getVendorDir(): string |
| 44 | { |
| 45 | $config = $this->get('config'); |
| 46 | $vendorDir = $config['vendor-dir'] ?? 'vendor'; |
| 47 | |
| 48 | return StringUtil::addTrailingSlash($this->packageDir . $vendorDir); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * @param string[] $extraExcludes |
| 53 | * |
| 54 | * @return void |
| 55 | */ |
| 56 | |
| 57 | public function setExtraExcludes(array $extraExcludes) |
| 58 | { |
| 59 | $this->extraExcludes = $extraExcludes; |
| 60 | } |
| 61 | } |
| 62 |