MoreThanOne   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
eloc 11
dl 0
loc 25
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getLogMessage() 0 8 2
A getModelLabel() 0 4 1
A getLogCategory() 0 2 1
1
<?php
2
namespace execut\import\components\parser\exception;
3
4
5
class MoreThanOne extends Exception
6
{
7
    public $attributes = null;
8
    public $modelClass = null;
9
    public function getLogMessage() {
10
        $label = $this->getModelLabel();
11
        $attributes = [];
12
        foreach ($this->attributes as $key => $attribute) {
13
            $attributes[] = $key . '=' . $attribute;
14
        }
15
16
        return $label . ' with attributes ' . implode(', ', $attributes) . ' founded more whan one record';
17
    }
18
19
    public function getLogCategory() {
20
        return 'import.moreThanOne.' . str_replace(' ', '', $this->getModelLabel());
21
    }
22
23
    /**
24
     * @return mixed
25
     */
26
    protected function getModelLabel()
27
    {
28
        $class = $this->modelClass;
29
        return $class;
30
    }
31
}