Test Failed
Push — master ( d7d4d0...ddcac2 )
by Alex
41s
created

XMLDateInterval   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 3
c 2
b 1
f 1
lcom 0
cbo 0
dl 0
loc 27
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 13 3
1
<?php
2
3
namespace AlgoWeb\xsdTypes\AxillaryClasses;
4
5
class XMLDateInterval
6
{
7
    /**
8
     * formating string like ISO 8601 (PnYnMnDTnHnMnS).
9
     */
10
    const INTERVAL_ISO8601 = 'P%yY%mM%dDT%hH%iM%sS';
11
    public $pattern = 'PnYnMnDTnHnMnS';
12
13
    /**
14
     * formating the interval like ISO 8601 (PnYnMnDTnHnMnS).
15
     *
16
     * @return string
17
     */
18
    public function __toString()
19
    {
20
        $sReturn = '';
21
        for ($i = 0; $i < strlen($this->pattern); $i++) {
22
            if ($this->pattern[$i] == 'n') {
23
                $v = strtolower($this->pattern[$i + 1]);
24
                $sReturn .= $this->$v;
25
                continue;
26
            }
27
            $sReturn .= $this->pattern[$i];
28
        }
29
        return $sReturn;
30
    }
31
}
32