getValidationMessages()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 2
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Logikos\Util\Config;
4
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
}