Completed
Push — master ( fe4c2e...b05117 )
by Michael
12s
created

Calendar::decodeYear()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4.0312

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.2
ccs 7
cts 8
cp 0.875
cc 4
eloc 10
nc 5
nop 3
crap 4.0312
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 interpreteting '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
            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