Completed
Push — xmfissue33-34 ( 2d141e...61e810 )
by Richard
05:30
created

Calendar   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 72.72%

Importance

Changes 0
Metric Value
dl 0
loc 29
ccs 8
cts 11
cp 0.7272
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A decodeYear() 0 16 4
1
<?php
2
3
namespace Xoops\Core\Locale\Punic;
4
5
/**
6
 * Overrides for Punic\Calendar.
7
 */
8
class Calendar extends \Punic\Calendar
9
{
10
    /**
11
     * Change to disable interpreting 'yy' as forcing 2 digit year
12
     *
13
     * Instead of interpreting 2015 as '15' it will be '2015', while year 1 would be reported as '01'
14
     *
15
     * @param \DateTime $value
16
     * @param           $count
17
     * @param           $locale
18
     * @return string
19
     */
20 12
    protected static function decodeYear(\DateTime $value, $count, $locale)
21
    {
22
        switch ($count) {
23 12
            case 1:
24 10
                return strval(intval($value->format('Y')));
25 2
            case 2:
26
                //return $value->format('y');
27 2
            default:
28 2
                $s = $value->format('Y');
29 2
                if (!isset($s[$count])) {
30
                    $s = str_pad($s, $count, '0', STR_PAD_LEFT);
31
                }
32
33 2
                return $s;
34
        }
35
    }
36
}
37