canada-fr.php ➔ easter()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 25

Duplication

Lines 25
Ratio 100 %

Importance

Changes 0
Metric Value
cc 4
nc 8
nop 2
dl 25
loc 25
rs 9.52
c 0
b 0
f 0
1
<?php
2
/*
3
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright   {@link http://xoops.org/ XOOPS Project}
14
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
15
 * @package
16
 * @since
17
 * @author       XOOPS Development Team,
18
 * @author       Antiques Promotion (http://www.antiquespromotion.ca)
19
 */
20
21 View Code Duplication
if (!function_exists('easter')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
    /**
23
     * @param $y
24
     * @param $holidays
25
     */
26
    function easter($y, &$holidays)
0 ignored issues
show
Unused Code introduced by
The parameter $holidays is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
27
    {
28
        $e = 21 + easter_days($y);
29
        if ($e > 31) {
30
            $e  -= 31;
31
            $em = 4;
32
        } else {
33
            $em = 3;
34
        }
35
        $f = $e - 2;
36
        $m = $e + 1;
37
        if ($f > 0) {
38
            $holidays["$y-$em-$f"] = 'Vendredi Saint';
39
        } else {
40
            $f                   = 31 - $f;
41
            $holidays["$y-3-$f"] = 'Vendredi Saint';
42
        }
43
        $holidays["$y-$em-$e"] = 'P&acirc;ques';
44
        if ($m > 31) {
45
            $m                   -= 31;
46
            $holidays["$y-4-$m"] = 'Lundi de P&acirc;ques';
47
        } else {
48
            $holidays["$y-$em-$m"] = 'Lundi de P&acirc;ques';
49
        }
50
    }
51
}
52
53
$this->holidays = array();
54
$start          = (int)date('Y') - 10;
55
$end            = $start + 30;
56
57 View Code Duplication
for ($y = $start; $y < $end; ++$y) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
58
    easter($y, $this->holidays);
59
    $v = ((int)date('N', strtotime("$y-5-25")) == 1) ? '25' : date('j', strtotime('Last Monday', strtotime("$y-5-25")));
60
    $m = date('j', strtotime('+2 Sunday', strtotime("$y-5-1")));
61
    $f = date('j', strtotime('+3 Sunday', strtotime("$y-6-1")));
62
    $c = date('j', strtotime('+1 Monday', strtotime("$y-8-1")));
63
    $l = date('j', strtotime('+1 Monday', strtotime("$y-9-1")));
64
    $t = date('j', strtotime('+2 Monday', strtotime("$y-10-1")));
65
66
    $this->holidays["$y-1-1"]   = 'Jour de l\'an';
67
    $this->holidays["$y-2-14"]  = 'St-Valentin';
68
    $this->holidays["$y-3-17"]  = 'St-Patrick';
69
    $this->holidays["$y-4-22"]  = 'Jour de la terre';
70
    $this->holidays["$y-5-$m"]  = 'F&ecirc;te des m&egrave;re';
71
    $this->holidays["$y-5-$v"]  = 'F&ecirc;te de la reine';
72
    $this->holidays["$y-6-$f"]  = 'F&ecirc;te des p&egrave;re';
73
    $this->holidays["$y-6-24"]  = 'St-Jean-Baptiste';
74
    $this->holidays["$y-7-1"]   = 'F&ecirc;te du Canada';
75
    $this->holidays["$y-8-$c"]  = 'Cong&eacute; provincial';
76
    $this->holidays["$y-9-$l"]  = 'F&ecirc;te du travail';
77
    $this->holidays["$y-10-$t"] = 'Action de gr&acirc;ce';
78
    $this->holidays["$y-10-31"] = 'Halloween';
79
    $this->holidays["$y-11-11"] = 'Jour du souvenir';
80
    $this->holidays["$y-12-25"] = 'No&euml;l';
81
    $this->holidays["$y-12-26"] = 'Boxing Day';
82
}
83