| Total Complexity | 5 |
| Total Lines | 27 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | class InvalidConfigStateException extends ConfigException { |
||
| 6 | |||
| 7 | /** @var StrictConfig */ |
||
| 8 | private $config; |
||
| 9 | |||
| 10 | 4 | public function __construct(StrictConfig $config) { |
|
| 11 | 4 | $this->config = $config; |
|
| 12 | 4 | parent::__construct($this->getMessagesAsYmlString()); |
|
| 13 | 4 | } |
|
| 14 | |||
| 15 | 4 | public function getMessagesAsYmlString() { |
|
| 16 | 4 | $string = ''; |
|
| 17 | 4 | foreach ($this->config->validationMessages() as $fieldName => $messages) { |
|
| 18 | 3 | $string .= sprintf( |
|
| 19 | 3 | "\n%s:\n- %s", |
|
| 20 | 3 | $fieldName, |
|
| 21 | 3 | implode("\n- ", $messages) |
|
| 22 | ); |
||
| 23 | } |
||
| 24 | 4 | return trim($string); |
|
| 25 | } |
||
| 26 | |||
| 27 | 1 | public function getValidationMessages() { |
|
| 28 | 1 | return $this->config->validationMessages(); |
|
| 29 | } |
||
| 30 | |||
| 31 | public function getConfig() { return $this->config; } |
||
| 32 | } |