Merge file:///media/external_data/workspace/web/sport-group
[sport-group.git] / library / Zend / Service / Technorati / Utils.php
blobfac6e20bca7e230e2be99d0d694242cb0736090d
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
15 * @category Zend
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 $
24 /**
25 * Collection of utilities for various Zend_Service_Technorati classes.
27 * @category Zend
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
35 /**
36 * Parses, validates and returns a valid Zend_Uri object
37 * from given $input.
39 * @param string|Zend_Uri_Http $input
40 * @return null|Zend_Uri_Http
41 * @throws Zend_Service_Technorati_Exception
42 * @static
44 public static function normalizeUriHttp($input)
46 // allow null as value
47 if ($input === null) {
48 return null;
51 /**
52 * @see Zend_Uri
54 require_once 'Zend/Uri.php';
55 if ($input instanceof Zend_Uri_Http) {
56 $uri = $input;
57 } else {
58 try {
59 $uri = Zend_Uri::factory((string) $input);
61 // wrap exception under Zend_Service_Technorati_Exception object
62 catch (Exception $e) {
63 /**
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)) {
73 /**
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");
81 return $uri;
83 /**
84 * Parses, validates and returns a valid Zend_Date object
85 * from given $input.
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
94 * @static
96 public static function normalizeDate($input)
98 /**
99 * @see Zend_Date
101 require_once 'Zend/Date.php';
103 * @see Zend_Locale
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)) {
109 return $input;
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);
116 } else {
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() {}