7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
16 * @package Zend_Service
17 * @subpackage Technorati
18 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id: Utils.php 16211 2009-06-21 19:23:55Z thomas $
25 * Collection of utilities for various Zend_Service_Technorati classes.
28 * @package Zend_Service
29 * @subpackage Technorati
30 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
31 * @license http://framework.zend.com/license/new-bsd New BSD License
33 class Zend_Service_Technorati_Utils
36 * Parses, validates and returns a valid Zend_Uri object
39 * @param string|Zend_Uri_Http $input
40 * @return null|Zend_Uri_Http
41 * @throws Zend_Service_Technorati_Exception
44 public static function normalizeUriHttp($input)
46 // allow null as value
47 if ($input === null) {
54 require_once 'Zend/Uri.php';
55 if ($input instanceof Zend_Uri_Http
) {
59 $uri = Zend_Uri
::factory((string) $input);
61 // wrap exception under Zend_Service_Technorati_Exception object
62 catch (Exception
$e) {
64 * @see Zend_Service_Technorati_Exception
66 require_once 'Zend/Service/Technorati/Exception.php';
67 throw new Zend_Service_Technorati_Exception($e->getMessage());
71 // allow inly Zend_Uri_Http objects or child classes
72 if (!($uri instanceof Zend_Uri_Http
)) {
74 * @see Zend_Service_Technorati_Exception
76 require_once 'Zend/Service/Technorati/Exception.php';
77 throw new Zend_Service_Technorati_Exception(
78 "Invalid URL $uri, only HTTP(S) protocols can be used");
84 * Parses, validates and returns a valid Zend_Date object
87 * $input can be either a string, an integer or a Zend_Date object.
88 * If $input is string or int, it will be provided to Zend_Date as it is.
89 * If $input is a Zend_Date object, the object instance will be returned.
91 * @param mixed|Zend_Date $input
92 * @return null|Zend_Date
93 * @throws Zend_Service_Technorati_Exception
96 public static function normalizeDate($input)
101 require_once 'Zend/Date.php';
105 require_once 'Zend/Locale.php';
107 // allow null as value and return valid Zend_Date objects
108 if (($input === null) ||
($input instanceof Zend_Date
)) {
112 // due to a BC break as of ZF 1.5 it's not safe to use Zend_Date::isDate() here
113 // see ZF-2524, ZF-2334
114 if (@strtotime
($input) !== FALSE) {
115 return new Zend_Date($input);
118 * @see Zend_Service_Technorati_Exception
120 require_once 'Zend/Service/Technorati/Exception.php';
121 throw new Zend_Service_Technorati_Exception("'$input' is not a valid Date/Time");
126 * @todo public static function xpathQueryAndSet() {}
130 * @todo public static function xpathQueryAndSetIf() {}
134 * @todo public static function xpathQueryAndSetUnless() {}