Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into rfc/escaper
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 128 changed files with 2,322 additions and 3,096 deletions.
8 changes: 8 additions & 0 deletions src/Exception/BadMethodCallException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Zend\Feed\Exception;

class BadMethodCallException
extends \BadMethodCallException
implements ExceptionInterface
{}
12 changes: 2 additions & 10 deletions src/Exception.php → src/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,14 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Feed;
namespace Zend\Feed\Exception;

/**
* Feed exceptions
*
* Class to represent exceptions that occur during Feed operations.
*
* @uses \Exception
* @category Zend
* @package Zend_Feed
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Exception extends \Exception
interface ExceptionInterface
{}

8 changes: 8 additions & 0 deletions src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Zend\Feed\Exception;

class InvalidArgumentException
extends \InvalidArgumentException
implements ExceptionInterface
{}
8 changes: 8 additions & 0 deletions src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Zend\Feed\Exception;

class RuntimeException
extends \RuntimeException
implements ExceptionInterface
{}
96 changes: 52 additions & 44 deletions src/PubSubHubbub/AbstractCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,27 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Feed\PubSubHubbub;

use Traversable;
use Zend\Stdlib\ArrayUtils;
use Zend\Http\PhpEnvironment\Response as PhpResponse;

/**
* @uses \Zend\Feed\PubSubHubbub\Callback
* @uses \Zend\Feed\PubSubHubbub\Exception
* @uses \Zend\Feed\PubSubHubbub\HttpResponse
* @category Zend
* @package Zend_Feed_Pubsubhubbub
* @subpackage Callback
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class AbstractCallback implements Callback
abstract class AbstractCallback implements CallbackInterface
{
/**
* An instance of Zend_Feed_Pubsubhubbub_Model_SubscriptionPersistence used
* to background save any verification tokens associated with a subscription
* An instance of Zend\Feed\Pubsubhubbub\Model\SubscriptionPersistenceInterface
* used to background save any verification tokens associated with a subscription
* or other.
*
* @var \Zend\Feed\PubSubHubbub\Model\SubscriptionPersistence
* @var Model\SubscriptionPersistenceInterface
*/
protected $_storage = null;

Expand All @@ -50,7 +48,7 @@ abstract class AbstractCallback implements Callback
* Zend\Feed\Pubsubhubbub\HttpResponse which shares an unenforced interface with
* (i.e. not inherited from) Zend\Controller\Response\Http.
*
* @var Zend_Feed_Pubsubhubbub_HttpResponse|\Zend\Controller\Response\Http
* @var HttpResponse|PhpResponse
*/
protected $_httpResponse = null;

Expand All @@ -62,61 +60,69 @@ abstract class AbstractCallback implements Callback
protected $_subscriberCount = 1;

/**
* Constructor; accepts an array or Zend\Config instance to preset
* Constructor; accepts an array or Traversable object to preset
* options for the Subscriber without calling all supported setter
* methods in turn.
*
* @param array|\Zend\Config\Config $options Options array or \Zend\Config\Config instance
* @param array|Traversable $options Options array or Traversable object
*/
public function __construct($config = null)
public function __construct($options = null)
{
if ($config !== null) {
$this->setConfig($config);
if ($options !== null) {
$this->setOptions($options);
}
}

/**
* Process any injected configuration options
*
* @param array|\Zend\Config\Config $options Options array or \Zend\Config\Config instance
* @return \Zend\Feed\PubSubHubbub\AbstractCallback
* @param array|Traversable $options Options array or Traversable object
* @return AbstractCallback
* @throws Exception\InvalidArgumentException
*/
public function setConfig($config)
public function setOptions($options)
{
if ($config instanceof \Zend\Config\Config) {
$config = $config->toArray();
} elseif (!is_array($config)) {
throw new Exception('Array or Zend_Config object'
. 'expected, got ' . gettype($config));
if ($options instanceof Traversable) {
$options = ArrayUtils::iteratorToArray($options);
}
if (array_key_exists('storage', $config)) {
$this->setStorage($config['storage']);

if (!is_array($options)) {
throw new Exception\InvalidArgumentException('Array or Traversable object'
. 'expected, got ' . gettype($options));
}

if (is_array($options)) {
$this->setOptions($options);
}

if (array_key_exists('storage', $options)) {
$this->setStorage($options['storage']);
}
return $this;
}

/**
* Send the response, including all headers.
* If you wish to handle this via Zend_Controller, use the getter methods
* If you wish to handle this via Zend_Http, use the getter methods
* to retrieve any data needed to be set on your HTTP Response object, or
* simply give this object the HTTP Response instance to work with for you!
*
* @return void
*/
public function sendResponse()
{
$this->getHttpResponse()->sendResponse();
$this->getHttpResponse()->send();
}

/**
* Sets an instance of Zend\Feed\Pubsubhubbub\Model\SubscriptionPersistence used
* to background save any verification tokens associated with a subscription
* or other.
*
* @param \Zend\Feed\PubSubHubbub\Model\SubscriptionPersistence $storage
* @return \Zend\Feed\PubSubHubbub\AbstractCallback
* @param Model\SubscriptionPersistenceInterface $storage
* @return AbstractCallback
*/
public function setStorage(Model\SubscriptionPersistence $storage)
public function setStorage(Model\SubscriptionPersistenceInterface $storage)
{
$this->_storage = $storage;
return $this;
Expand All @@ -127,12 +133,13 @@ public function setStorage(Model\SubscriptionPersistence $storage)
* to background save any verification tokens associated with a subscription
* or other.
*
* @return \Zend\Feed\PubSubHubbub\Model\SubscriptionPersistence
* @return Model\SubscriptionPersistenceInterface
* @throws Exception\RuntimeException
*/
public function getStorage()
{
if ($this->_storage === null) {
throw new Exception('No storage object has been'
throw new Exception\RuntimeException('No storage object has been'
. ' set that subclasses Zend\Feed\Pubsubhubbub\Model\SubscriptionPersistence');
}
return $this->_storage;
Expand All @@ -143,18 +150,16 @@ public function getStorage()
* Zend\Feed\Pubsubhubbub\HttpResponse which shares an unenforced interface with
* (i.e. not inherited from) Zend\Controller\Response\Http.
*
* @param Zend\Feed\Pubsubhubbub\HttpResponse|\Zend\Controller\Response\Http $httpResponse
* @return \Zend\Feed\PubSubHubbub\AbstractCallback
* @param HttpResponse|PhpResponse $httpResponse
* @return AbstractCallback
* @throws Exception\InvalidArgumentException
*/
public function setHttpResponse($httpResponse)
{
if (!is_object($httpResponse)
|| (!$httpResponse instanceof HttpResponse
&& !$httpResponse instanceof \Zend\Controller\Response\Http)
) {
throw new Exception('HTTP Response object must'
if (!$httpResponse instanceof HttpResponse && !$httpResponse instanceof PhpResponse) {
throw new Exception\InvalidArgumentException('HTTP Response object must'
. ' implement one of Zend\Feed\Pubsubhubbub\HttpResponse or'
. ' Zend\Controller\Response\Http');
. ' Zend\Http\PhpEnvironment\Response');
}
$this->_httpResponse = $httpResponse;
return $this;
Expand All @@ -165,7 +170,7 @@ public function setHttpResponse($httpResponse)
* Zend\Feed\Pubsubhubbub\HttpResponse which shares an unenforced interface with
* (i.e. not inherited from) Zend\Controller\Response\Http.
*
* @return Zend\Feed\Pubsubhubbub\HttpResponse|\Zend\Controller\Response\Http
* @return HttpResponse|PhpResponse
*/
public function getHttpResponse()
{
Expand All @@ -181,13 +186,14 @@ public function getHttpResponse()
* Defaults to 1 if left unchanged.
*
* @param string|int $count
* @return \Zend\Feed\PubSubHubbub\AbstractCallback
* @return AbstractCallback
* @throws Exception\InvalidArgumentException
*/
public function setSubscriberCount($count)
{
$count = intval($count);
if ($count <= 0) {
throw new Exception('Subscriber count must be'
throw new Exception\InvalidArgumentException('Subscriber count must be'
. ' greater than zero');
}
$this->_subscriberCount = $count;
Expand All @@ -207,6 +213,7 @@ public function getSubscriberCount()

/**
* Attempt to detect the callback URL (specifically the path forward)
* @return string
*/
protected function _detectCallbackUrl()
{
Expand Down Expand Up @@ -261,6 +268,7 @@ protected function _getHttpHost()
* Retrieve a Header value from either $_SERVER or Apache
*
* @param string $header
* @return bool|string
*/
protected function _getHeader($header)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Feed\PubSubHubbub;

/**
Expand All @@ -31,7 +28,7 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Callback
interface CallbackInterface
{
/**
* Handle any callback from a Hub Server responding to a subscription or
Expand All @@ -58,7 +55,7 @@ public function sendResponse();
* Zend_Feed_Pubsubhubbub_HttpResponse which shares an unenforced interface with
* (i.e. not inherited from) Zend_Controller_Response_Http.
*
* @param Zend\Feed\PubSubHubbub\HttpResponse|\Zend\Controller\Response\Http $httpResponse
* @param HttpResponse|\Zend\Http\PhpEnvironment\Response $httpResponse
*/
public function setHttpResponse($httpResponse);

Expand All @@ -67,7 +64,7 @@ public function setHttpResponse($httpResponse);
* Zend_Feed_Pubsubhubbub_HttpResponse which shares an unenforced interface with
* (i.e. not inherited from) Zend_Controller_Response_Http.
*
* @return Zend\Feed\PubSubHubbub\HttpResponse|\Zend\Controller\Response\Http
* @return HttpResponse|\Zend\Http\PhpEnvironment\Response
*/
public function getHttpResponse();
}
34 changes: 0 additions & 34 deletions src/PubSubHubbub/Exception.php

This file was deleted.

8 changes: 8 additions & 0 deletions src/PubSubHubbub/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Zend\Feed\PubSubHubbub\Exception;

use Zend\Feed\Exception\ExceptionInterface as Exception;

interface ExceptionInterface extends Exception
{}
10 changes: 10 additions & 0 deletions src/PubSubHubbub/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Zend\Feed\PubSubHubbub\Exception;

use Zend\Feed\Exception;

class InvalidArgumentException
extends Exception\InvalidArgumentException
implements ExceptionInterface
{}
10 changes: 10 additions & 0 deletions src/PubSubHubbub/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Zend\Feed\PubSubHubbub\Exception;

use Zend\Feed\Exception;

class RuntimeException
extends Exception\RuntimeException
implements ExceptionInterface
{}
Loading

0 comments on commit de5ff9e

Please sign in to comment.