City::getYesterday()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 6

Duplication

Lines 8
Ratio 100 %
Metric Value
dl 8
loc 8
rs 9.4285
cc 2
eloc 6
nc 2
nop 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: ignatenkov
5
 * Date: 21.08.15
6
 * Time: 1:22
7
 */
8
9
namespace YaWeather\Models;
10
11
12
class City {
13
14
    public $city;
15
    public $country;
16
    public $region;
17
18
    public $fact;
19
    public $yesterday;
20
21
    public $days;
22
23
24
    /**
25
     * Get current model day
26
     * @return string
27
     */
28 View Code Duplication
    public function getCurrentDay() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
29
        $current = date("Y-m-d");
30
        if(isset($this->days[$current]))
31
            return $this->days[$current];
32
        else
33
            return "not found current day";
34
    }
35
36
    /**
37
     * Get List models Day
38
     * @return mixed
39
     */
40 View Code Duplication
    public function getListDays() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
41
        $current = date("Y-m-d");
42
        if(isset($this->days[$current]))
43
            unset($this->days[$current]);
44
45
        return $this->days;
46
    }
47
48
    /**
49
     * Get yesterday model day
50
     * @return string
51
     */
52 View Code Duplication
    public function getYesterday() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
53
        $yesterday = date("Y-m-d", time() - 86400);
54
55
        if(isset($this->days[$yesterday]))
56
            return $this->days[$yesterday];
57
        else
58
            return "not found yesterday day";
59
    }
60
61
62
63
64
    /*public $listDay = array();
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
65
    private $xml;
66
67
    public function __construct($fileName) {
68
69
        $this->xml = simplexml_load_file($fileName);
70
        /*$day = new Day();
71
        $day->p = 0;
72
        $day->p1 = 1;
73
74
        $this->listDay[] = $day;*/
75
        //echo $fileName;
76
        //$xml = simplexml_load_file($fileName, "Day");
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
77
78
79
80
        //$xml1 = $file = file_get_contents($fileName, true);;
0 ignored issues
show
Unused Code Comprehensibility introduced by
53% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
81
        //var_dump($xml);
82
        //$xml1 = simplexml_load_string($xml, 'Day');
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
83
        //var_dump($xml->day[0]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
80% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
84
        //var_dump($xml);
85
        //var_dump($this->listDay);
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
86
    /*}
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
87
88
    public function getListDay() {
89
90
91
92
93
        foreach ($this->xml->day as $day) {
94
            $this->listDay[] = new Day($day);
95
            //var_dump($day->sunrise);
96
97
        }
98
99
        return $this->listDay;
100
101
    }*/
102
103
104
    /*public function getListDay() {
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
105
        return $this->listDay;
106
    }*/
107
108
}