OfferParam   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 36
rs 10
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A write() 0 17 4
A writeCustomTags() 0 4 2
1
<?php
2
3
namespace iamsaint\yml\components;
4
5
use iamsaint\yml\BaseObject;
6
use XMLWriter;
7
8
/**
9
 * Class OfferParam
10
 * @package iamsaint\yml\components
11
 *
12
 * @property string $name
13
 * @property string $text
14
 * @property string $unit
15
 * @property Tag[] $customTags
16
 */
17
class OfferParam extends BaseObject
18
{
19
    public $name;
20
    public $text;
21
    public $unit;
22
    public $customTags = [];
23
24
    /**
25
     * @param XMLWriter $writer
26
     */
27
    public function write($writer): void
28
    {
29
        $writer->startElement('param');
30
31
        if (null !== $this->name) {
32
            $writer->writeAttribute('name', $this->name);
33
        }
34
        if (null !== $this->unit) {
35
            $writer->writeAttribute('unit', $this->unit);
36
        }
37
        if (null !== $this->text) {
38
            $writer->text($this->text);
39
        }
40
41
        $this->writeCustomTags($writer);
42
43
        $writer->endElement();
44
    }
45
46
    /**
47
     * @param XMLWriter $writer
48
     */
49
    public function writeCustomTags($writer): void
50
    {
51
        foreach ($this->customTags as $tag) {
52
            $tag->write($writer);
53
        }
54
    }
55
}
56