DateTime::replaceDateNumbers()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file is part of the EasyBanglaDate package.
5
 *
6
 * Copyright (c) 2015 Roni Saha
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace EasyBanglaDate\Types;
13
14
use EasyBanglaDate\Common\BaseDateTime;
15
16
class DateTime extends BaseDateTime
17
{
18
19
    protected function replaceDateNumbers($format)
20
    {
21
        $numbersItems = array('d', 'j', 'm', 'n', 't', 'Y', 'y');
22
        $out = $format;
23
24
        foreach ($numbersItems as $item) {
25
            $out = str_replace($item, $this->_format($item), $out);
26
        }
27
28
        return $out;
29
    }
30
31
    protected function replaceMonths($format)
32
    {
33
        return $this->getInBengali($format, array('F', 'M'));
34
    }
35
36
    public function format($format)
37
    {
38
        $out = $this->replaceTimes($format);
39
        $out = $this->replaceTimePrefix($out);
40
        $out = $this->replaceSuffix($out);
41
        $out = $this->replaceDateNumbers($out);
42
        $out = $this->replaceMonths($out);
43
        $out = $this->replaceDays($out);
44
        $out = $this->replaceMeridian($out);
45
46
        return $this->translateNumbers($out);
47
    }
48
49
    public function enFormat($format) {
50
        return $this->_format($format);
51
    }
52
}