Passed
Pull Request — master (#2)
by tsms
01:39
created

Calendar_Decorator_Uri   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 102
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 9
dl 0
loc 102
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setFragments() 0 3 1
A this() 0 3 1
A setScalar() 0 3 1
A prev() 0 3 1
A setSeparator() 0 3 1
A __construct() 0 3 1
1
<?php
2
/* vim: set expandtab tabstop=4 shiftwidth=4: */
3
4
/**
5
 * Contains the Calendar_Decorator_Uri class
6
 *
7
 * PHP versions 4 and 5
8
 *
9
 * LICENSE: Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice, this list of conditions and the following disclaimer.
13
 * 2. Redistributions in binary form must reproduce the above copyright
14
 *    notice, this list of conditions and the following disclaimer in the
15
 *    documentation and/or other materials provided with the distribution.
16
 * 3. The name of the author may not be used to endorse or promote products
17
 *    derived from this software without specific prior written permission.
18
 *
19
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
20
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
 * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
23
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 *
30
 * @category  Date and Time
31
 * @package   Calendar
32
 * @author    Harry Fuecks <[email protected]>
33
 * @author    Lorenzo Alberton <[email protected]>
34
 * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
35
 * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
36
 * @version   CVS: $Id$
37
 * @link      http://pear.php.net/package/Calendar
38
 */
39
namespace Pear\Calendar\Decorator;
40
41
/**
42
 * Allows Calendar include path to be redefined
43
 * @ignore
44
 */
45
if (!defined('CALENDAR_ROOT')) {
46
    define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
47
}
48
49
/**
50
 * Load Calendar decorator base class
51
 */
52
require_once CALENDAR_ROOT.'Decorator.php';
53
54
/**
55
 * Load the Uri utility
56
 */
57
require_once CALENDAR_ROOT.'Util'.DIRECTORY_SEPARATOR.'Uri.php';
58
59
/**
60
 * Decorator to help with building HTML links for navigating the calendar<br />
61
 * <b>Note:</b> for performance you should prefer Calendar_Util_Uri unless you
62
 * have a specific need to use a decorator
63
 * <code>
64
 * $Day = new Calendar_Day(2003, 10, 23);
65
 * $Uri = new Calendar_Decorator_Uri($Day);
66
 * $Uri->setFragments('year', 'month', 'day');
67
 * echo $Uri->getPrev(); // Displays year=2003&month=10&day=22
68
 * </code>
69
 *
70
 * @category  Date and Time
71
 * @package   Calendar
72
 * @author    Harry Fuecks <[email protected]>
73
 * @author    Lorenzo Alberton <[email protected]>
74
 * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
75
 * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
76
 * @link      http://pear.php.net/package/Calendar
77
 * @see       Calendar_Util_Uri
78
 * @access    public
79
 */
80
class Calendar_Decorator_Uri extends Calendar_Decorator
81
{
82
83
    /**
84
     * @var Calendar_Util_Uri
0 ignored issues
show
Bug introduced by
The type Pear\Calendar\Decorator\Calendar_Util_Uri was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
85
     * @access private
86
     */
87
    var $Uri;
88
89
    /**
90
     * Constructs Calendar_Decorator_Uri
91
     *
92
     * @param object &$Calendar subclass of Calendar
93
     *
94
     * @access public
95
     */
96
    function __construct(&$Calendar)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
97
    {
98
        parent::__construct($Calendar);
99
    }
100
101
    /**
102
     * Sets the URI fragment names
103
     *
104
     * @param string $y URI fragment for year
105
     * @param string $m (optional) URI fragment for month
106
     * @param string $d (optional) URI fragment for day
107
     * @param string $h (optional) URI fragment for hour
108
     * @param string $i (optional) URI fragment for minute
109
     * @param string $s (optional) URI fragment for second
110
     *
111
     * @return void
112
     * @access public
113
     */
114
    function setFragments($y, $m = null, $d = null, $h = null, $i = null, $s = null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
115
    {
116
        $this->Uri = new Calendar_Util_Uri($y, $m, $d, $h, $i, $s);
117
    }
118
119
    /**
120
     * Sets the separator string between fragments
121
     *
122
     * @param string $separator url fragment separator e.g. /
123
     *
124
     * @return void
125
     * @access public
126
     */
127
    function setSeparator($separator)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
128
    {
129
        $this->Uri->separator = $separator;
130
    }
131
132
    /**
133
     * Puts Uri decorator into "scalar mode" - URI variable names are not returned
134
     *
135
     * @param boolean $state (optional)
136
     *
137
     * @return void
138
     * @access public
139
     */
140
    function setScalar($state = true)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
141
    {
142
        $this->Uri->scalar = $state;
143
    }
144
145
    /**
146
     * Gets the URI string for the previous calendar unit
147
     *
148
     * @param string $method calendar unit to fetch uri for (year, month, week or day etc)
149
     *
150
     * @return string
151
     * @access public
152
     */
153
    function prev($method)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
154
    {
155
        return $this->Uri->prev($this, $method);
156
    }
157
158
    /**
159
     * Gets the URI string for the current calendar unit
160
     *
161
     * @param string $method calendar unit to fetch uri for (year,month,week or day etc)
162
     *
163
     * @return string
164
     * @access public
165
     */
166
    function this($method)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
167
    {
168
        return $this->Uri->this($this, $method);
169
    }
170
171
    /**
172
     * Gets the URI string for the next calendar unit
173
     *
174
     * @param string $method calendar unit to fetch uri for (year,month,week or day etc)
175
     *
176
     * @return string
177
     * @access public
178
     */
179
    function next($method)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
180
    {
181
        return $this->Uri->next($this, $method);
182
    }
183
}
184