PageBreakpoint   A
last analyzed

Complexity

Total Complexity 20

Size/Duplication

Total Lines 183
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 20
lcom 1
cbo 1
dl 0
loc 183
rs 10
c 0
b 0
f 0

18 Methods

Rating   Name   Duplication   Size   Complexity  
A getImages() 0 3 1
A getImageGroupsSizes() 0 3 1
A getIdPage() 0 3 1
A getHash() 0 3 1
A getPath() 0 3 1
A getExtraData() 0 3 1
A getTemplateHash() 0 3 1
A setTemplateHash() 0 3 1
A setExtraData() 0 3 1
A setIdPage() 0 3 1
A setHash() 0 3 1
A setPath() 0 10 3
A setImages() 0 3 1
A setImageGroupsSizes() 0 3 1
A getFileName() 0 4 1
A getFullPath() 0 3 1
A getData() 0 9 1
A getFullFileName() 0 3 1
1
<?php
2
3
namespace Columnis\Model;
4
5
use Columnis\Exception\Templates\PathNotFoundException;
6
7
class PageBreakpoint {
8
9
    const BREAKPOINT_FILE = 'breakpoints.tpl';
10
    const BREAKPOINT_DIR = 'breakpoints';
11
12
    protected $idPage;
13
    protected $hash;
14
    protected $templateHash;
15
    protected $images;
16
    protected $path;
17
    protected $extraData;
18
    protected $imageGroupsSizes;
19
20
    /**
21
     * Returns the images array
22
     *
23
     * @return array
24
     */
25
    public function getImages() {
26
        return $this->images;
27
    }
28
29
    /**
30
     * Returns the imagegroups sizes groups array
31
     *
32
     * @return array
33
     */
34
    public function getImageGroupsSizes() {
35
        return $this->imageGroupsSizes;
36
    }
37
38
    /**
39
     * Returns page id
40
     *
41
     * @return int
42
     */
43
    public function getIdPage() {
44
        return $this->idPage;
45
    }
46
47
    /**
48
     * Returns breakpoints hash
49
     *
50
     * @return string
51
     */
52
    public function getHash() {
53
        return $this->hash;
54
    }
55
56
    /**
57
     * Return the path of breakpoint file
58
     * @return string
59
     */
60
    public function getPath() {
61
        return $this->path;
62
    }
63
64
    /**
65
     * Returns Extra data
66
     * @return array
67
     */
68
    public function getExtraData() {
69
        return $this->extraData;
70
    }
71
72
    /**
73
     * Returns template hash
74
     * 
75
     * @return string
76
     */
77
    public function getTemplateHash() {
78
        return $this->templateHash;
79
    }
80
81
    /**
82
     * Sets templaet hash
83
     * 
84
     * @param string $templateHash
85
     */
86
    public function setTemplateHash($templateHash) {
87
        $this->templateHash = $templateHash;
88
    }
89
90
    /**
91
     * Sets extra data
92
     * @param array $extraData
93
     */
94
    public function setExtraData($extraData) {
95
        $this->extraData = $extraData;
96
    }
97
98
    /**
99
     * Sets the page id
100
     *
101
     * @param int $idPage
102
     */
103
    public function setIdPage($idPage) {
104
        $this->idPage = $idPage;
105
    }
106
107
    /**
108
     * Sets the breackpoint hash
109
     *
110
     * @param string $hash
111
     */
112
    public function setHash($hash) {
113
        $this->hash = $hash;
114
    }
115
116
    /**
117
     * Sets the path of the breakpoint file
118
     *
119
     * @param string $path
120
     * @throws PathNotFoundException
121
     */
122
    public function setPath($path) {
123
        if($path === null) {
124
            throw new PathNotFoundException('Path can not be null.');
125
        }
126
        $absPath = realpath($path);
127
        if(!$absPath) {
128
            throw new PathNotFoundException('Path: '.$path.' does not exist.');
129
        }
130
        $this->path = $absPath;
131
    }
132
133
    /**
134
     * Sets the images array
135
     * @param array $images
136
     */
137
    public function setImages($images) {
138
        $this->images = $images;
139
    }
140
141
    /**
142
     * Sets the imagegroups sizes array
143
     * @param array $imageGroupsSizes
144
     *
145
     */
146
    public function setImageGroupsSizes($imageGroupsSizes) {
147
        $this->imageGroupsSizes = $imageGroupsSizes;
148
    }
149
150
    /**
151
     * Returns breakpoint file name
152
     * @return string
153
     */
154
    public function getFileName() {
155
        $fileNameHash = md5($this->getHash().$this->getTemplateHash());
156
        return $this->getIdPage().'-'.$fileNameHash.'.css';
157
    }
158
159
    /**
160
     * Returns breakpoint full path
161
     * @return string
162
     */
163
    public function getFullPath() {
164
        return $this->getPath().DIRECTORY_SEPARATOR.self::BREAKPOINT_DIR.DIRECTORY_SEPARATOR;
165
    }
166
167
    /**
168
     * Return an array with the util data
169
     * 
170
     * @return array
171
     */
172
    public function getData() {
173
        $data = array(
174
            'idPage' => $this->getIdPage(),
175
            'extra' => $this->getExtraData(),
176
            'images' => $this->getImages(),
177
            'imagesGroupsSizes' => $this->getImageGroupsSizes()
178
        );
179
        return $data;
180
    }
181
182
    /**
183
     * Returns breakpoint full file name
184
     * @return string
185
     */
186
    public function getFullFileName() {
187
        return $this->getFullPath().$this->getFileName();
188
    }
189
}
190
191
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...