MoreThanOne::getLogMessage()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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