FriendsOfPear /
Calendar
| 1 | <?php |
||
| 2 | /* vim: set expandtab tabstop=4 shiftwidth=4: */ |
||
| 3 | |||
| 4 | /** |
||
| 5 | * Contains the Calendar_Decorator_Wrapper 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 wrapping built children in another decorator |
||
| 45 | * |
||
| 46 | * @category Date and Time |
||
| 47 | * @package Calendar |
||
| 48 | * @author Harry Fuecks <[email protected]> |
||
| 49 | * @author Lorenzo Alberton <[email protected]> |
||
| 50 | * @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton |
||
| 51 | * @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) |
||
| 52 | * @link http://pear.php.net/package/Calendar |
||
| 53 | * @access public |
||
| 54 | */ |
||
| 55 | class Wrapper extends Decorator |
||
| 56 | { |
||
| 57 | /** |
||
| 58 | * Constructs Calendar_Decorator_Wrapper |
||
| 59 | * |
||
| 60 | * @param object &$Calendar subclass of Calendar |
||
| 61 | * |
||
| 62 | * @access public |
||
| 63 | */ |
||
| 64 | function __construct(&$Calendar) |
||
|
0 ignored issues
–
show
|
|||
| 65 | { |
||
| 66 | parent::__construct($Calendar); |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Wraps objects returned from fetch in the named Decorator class |
||
| 71 | * |
||
| 72 | * @param string $decorator name of Decorator class to wrap with |
||
| 73 | * |
||
| 74 | * @return object instance of named decorator |
||
| 75 | * @access public |
||
| 76 | */ |
||
| 77 | function & fetch($decorator) |
||
| 78 | { |
||
| 79 | $Calendar = parent::fetch(); |
||
| 80 | if ($Calendar) { |
||
| 81 | $ret = new $decorator($Calendar); |
||
| 82 | } else { |
||
| 83 | $ret = false; |
||
| 84 | } |
||
| 85 | return $ret; |
||
|
0 ignored issues
–
show
The expression
return $ret could also return false which is incompatible with the documented return type object. Did you maybe forget to handle an error condition?
If the returned type also contains false, it is an indicator that maybe an error condition leading to the specific return statement remains unhandled. Loading history...
|
|||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Wraps the returned calendar objects from fetchAll in the named decorator |
||
| 90 | * |
||
| 91 | * @param string $decorator name of Decorator class to wrap with |
||
| 92 | * |
||
| 93 | * @return array |
||
| 94 | * @access public |
||
| 95 | */ |
||
| 96 | function fetchAll($decorator) |
||
|
0 ignored issues
–
show
|
|||
| 97 | { |
||
| 98 | $children = parent::fetchAll(); |
||
| 99 | foreach ($children as $key => $Calendar) { |
||
| 100 | $children[$key] = new $decorator($Calendar); |
||
| 101 | } |
||
| 102 | return $children; |
||
| 103 | } |
||
| 104 | } |
||
| 105 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.