getMessagesAsYmlString()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 10
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
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
}