Passed
Push — master ( b47dcf...3f2121 )
by Aleksandr
04:26 queued 49s
created

Image   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 5
dl 0
loc 21
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPath() 0 3 1
A getCaption() 0 7 2
1
<?php
2
3
4
namespace Zenwalker\CommerceML\Model;
5
6
/**
7
 * Class Image
8
 *
9
 * @package Zenwalker\CommerceML\Model
10
 * @property string path
11
 * @property string caption
12
 */
13
class Image extends Simple
14
{
15
16
    /**
17
     * @return string
18
     */
19 1
    public function getPath()
20
    {
21 1
        return trim((string)$this->xml);
22
    }
23
24
    /**
25
     * @return string
26
     */
27 1
    public function getCaption()
28
    {
29 1
        if ($xml = $this->xpath("//c:ЗначениеРеквизита[contains(c:Значение, '{$this->path}#')]")) {
30 1
            return (string)current(\array_slice(explode('#', (string)$xml[0]->Значение), 1));
31
        }
32
33 1
        return '';
34
    }
35
}