-
Notifications
You must be signed in to change notification settings - Fork 1
/
CommandConfigValidator.php
executable file
·39 lines (32 loc) · 1.09 KB
/
CommandConfigValidator.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
<?php
/**
* This source file is available under :
* - GNU General Public License version 3 (GPLv3)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) sndsabin
*/
namespace SNDSABIN\ImportBundle\Traits;
use SNDSABIN\ImportBundle\Exception\ConfigValidatorException;
trait CommandConfigValidator
{
/**
* @return int
*
* @throws ConfigValidatorException
*/
public function validate(): int
{
if (!$this->config->get($this->class)) {
throw new ConfigValidatorException('class not configured correctly in import config');
}
if (!$this->file && !$this->config->get('base_directory')) {
throw new ConfigValidatorException('base_directory not configured correctly in import config');
}
if (!$this->file && !$this->config->get("{$this->class}.mapper")) {
throw new ConfigValidatorException("mapper not configured correctly in import config for {$this->class} class");
}
return true;
}
}