Uri   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 102
Duplicated Lines 0 %

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setScalar() 0 3 1
A setFragments() 0 3 1
A this() 0 3 1
A next() 0 3 1
A setSeparator() 0 3 1
A prev() 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
use PEAR\Calendar\Decorator;
42
43
/**
44
 * Decorator to help with building HTML links for navigating the calendar<br />
45
 * <b>Note:</b> for performance you should prefer Calendar_Util_Uri unless you
46
 * have a specific need to use a decorator
47
 * <code>
48
 * $Day = new Calendar_Day(2003, 10, 23);
49
 * $Uri = new Calendar_Decorator_Uri($Day);
50
 * $Uri->setFragments('year', 'month', 'day');
51
 * echo $Uri->getPrev(); // Displays year=2003&month=10&day=22
52
 * </code>
53
 *
54
 * @category  Date and Time
55
 * @package   Calendar
56
 * @author    Harry Fuecks <[email protected]>
57
 * @author    Lorenzo Alberton <[email protected]>
58
 * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
59
 * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
60
 * @link      http://pear.php.net/package/Calendar
61
 * @see       Uri
62
 * @access    public
63
 */
64
class Uri extends Decorator
65
{
66
67
    /**
68
     * @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...
69
     * @access private
70
     */
71
    var $Uri;
72
73
    /**
74
     * Constructs Calendar_Decorator_Uri
75
     *
76
     * @param object &$Calendar subclass of Calendar
77
     *
78
     * @access public
79
     */
80
    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...
81
    {
82
        parent::__construct($Calendar);
83
    }
84
85
    /**
86
     * Sets the URI fragment names
87
     *
88
     * @param string $y URI fragment for year
89
     * @param string $m (optional) URI fragment for month
90
     * @param string $d (optional) URI fragment for day
91
     * @param string $h (optional) URI fragment for hour
92
     * @param string $i (optional) URI fragment for minute
93
     * @param string $s (optional) URI fragment for second
94
     *
95
     * @return void
96
     * @access public
97
     */
98
    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...
99
    {
100
        $this->Uri = new \PEAR\Calendar\Util\Uri($y, $m, $d, $h, $i, $s);
0 ignored issues
show
Documentation Bug introduced by
It seems like new PEAR\Calendar\Util\Uri($y, $m, $d, $h, $i, $s) of type PEAR\Calendar\Util\Uri is incompatible with the declared type PEAR\Calendar\Decorator\Calendar_Util_Uri of property $Uri.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
101
    }
102
103
    /**
104
     * Sets the separator string between fragments
105
     *
106
     * @param string $separator url fragment separator e.g. /
107
     *
108
     * @return void
109
     * @access public
110
     */
111
    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...
112
    {
113
        $this->Uri->separator = $separator;
114
    }
115
116
    /**
117
     * Puts Uri decorator into "scalar mode" - URI variable names are not returned
118
     *
119
     * @param boolean $state (optional)
120
     *
121
     * @return void
122
     * @access public
123
     */
124
    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...
125
    {
126
        $this->Uri->scalar = $state;
127
    }
128
129
    /**
130
     * Gets the URI string for the previous calendar unit
131
     *
132
     * @param string $method calendar unit to fetch uri for (year, month, week or day etc)
133
     *
134
     * @return string
135
     * @access public
136
     */
137
    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...
138
    {
139
        return $this->Uri->prev($this, $method);
140
    }
141
142
    /**
143
     * Gets the URI string for the current calendar unit
144
     *
145
     * @param string $method calendar unit to fetch uri for (year,month,week or day etc)
146
     *
147
     * @return string
148
     * @access public
149
     */
150
    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...
151
    {
152
        return $this->Uri->this($this, $method);
153
    }
154
155
    /**
156
     * Gets the URI string for the next calendar unit
157
     *
158
     * @param string $method calendar unit to fetch uri for (year,month,week or day etc)
159
     *
160
     * @return string
161
     * @access public
162
     */
163
    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...
164
    {
165
        return $this->Uri->next($this, $method);
166
    }
167
}
168