From 40e400d3a97188476251371f8e817e729d3236ae Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 1 Jul 2010 14:36:46 -0400 Subject: [PATCH] Zend\ProgressBar cleanup - s/ProgressBar\Adapter\Adapter/ProgressBar\Adapter\AbstractAdapter/g - Updated tests and code to reflect change --- src/Adapter/{Adapter.php => AbstractAdapter.php} | 9 +++++---- src/Adapter/Console.php | 2 +- src/Adapter/JsPull.php | 11 ++++++----- src/Adapter/JsPush.php | 8 +++++--- src/ProgressBar.php | 2 +- test/ProgressBarTest.php | 2 +- 6 files changed, 19 insertions(+), 15 deletions(-) rename src/Adapter/{Adapter.php => AbstractAdapter.php} (95%) diff --git a/src/Adapter/Adapter.php b/src/Adapter/AbstractAdapter.php similarity index 95% rename from src/Adapter/Adapter.php rename to src/Adapter/AbstractAdapter.php index 15998a5..f9f6cfa 100644 --- a/src/Adapter/Adapter.php +++ b/src/Adapter/AbstractAdapter.php @@ -23,7 +23,8 @@ * @namespace */ namespace Zend\ProgressBar\Adapter; -use Zend\Config; + +use Zend\Config\Config; /** * Abstract class for Zend_ProgressBar_Adapters @@ -33,7 +34,7 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -abstract class Adapter +abstract class AbstractAdapter { /** * Option keys to skip when calling setOptions() @@ -57,7 +58,7 @@ public function __construct($options = null) { if (is_array($options)) { $this->setOptions($options); - } elseif ($options instanceof Config\Config) { + } elseif ($options instanceof Config) { $this->setConfig($options); } } @@ -68,7 +69,7 @@ public function __construct($options = null) * @param \Zend\Config\Config $config * @return \Zend\ProgressBar\Adapter\Adapter */ - public function setConfig(Config\Config $config) + public function setConfig(Config $config) { $this->setOptions($config->toArray()); diff --git a/src/Adapter/Console.php b/src/Adapter/Console.php index 2dd6941..e71c9ba 100644 --- a/src/Adapter/Console.php +++ b/src/Adapter/Console.php @@ -35,7 +35,7 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Console extends Adapter +class Console extends AbstractAdapter { /** * Percentage value of the progress diff --git a/src/Adapter/JsPull.php b/src/Adapter/JsPull.php index e4fe87e..01513f5 100644 --- a/src/Adapter/JsPull.php +++ b/src/Adapter/JsPull.php @@ -21,13 +21,14 @@ * @namespace */ namespace Zend\ProgressBar\Adapter; -use Zend\Json; + +use Zend\JSON\JSON; /** * Zend_ProgressBar_Adapter_JsPull offers a simple method for updating a * progressbar in a browser. * - * @uses \Zend\Json\Json + * @uses \Zend\JSON\JSON * @uses \Zend\ProgressBar\Adapter\Adapter * @category Zend * @package Zend_ProgressBar @@ -35,7 +36,7 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class JsPull extends Adapter +class JsPull extends AbstractAdapter { /** * Wether to exit after json data send or not @@ -78,7 +79,7 @@ public function notify($current, $max, $percent, $timeTaken, $timeRemaining, $te 'finished' => false ); - $data = Json\Json::encode($arguments); + $data = JSON::encode($arguments); // Output the data $this->_outputData($data); @@ -91,7 +92,7 @@ public function notify($current, $max, $percent, $timeTaken, $timeRemaining, $te */ public function finish() { - $data = Json\Json::encode(array('finished' => true)); + $data = JSON::encode(array('finished' => true)); $this->_outputData($data); } diff --git a/src/Adapter/JsPush.php b/src/Adapter/JsPush.php index e4f77ff..0d53880 100644 --- a/src/Adapter/JsPush.php +++ b/src/Adapter/JsPush.php @@ -22,11 +22,13 @@ */ namespace Zend\ProgressBar\Adapter; +use Zend\JSON\JSON; + /** * Zend_ProgressBar_Adapter_JsPush offers a simple method for updating a * progressbar in a browser. * - * @uses \Zend\Json\Json + * @uses \Zend\JSON\JSON * @uses \Zend\ProgressBar\Adapter\Adapter * @category Zend * @package Zend_ProgressBar @@ -34,7 +36,7 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class JsPush extends Adapter +class JsPush extends AbstractAdapter { /** * Name of the JavaScript method to call on update @@ -99,7 +101,7 @@ public function notify($current, $max, $percent, $timeTaken, $timeRemaining, $te ); $data = ''; // Output the data diff --git a/src/ProgressBar.php b/src/ProgressBar.php index 392e2be..71ba6bc 100644 --- a/src/ProgressBar.php +++ b/src/ProgressBar.php @@ -92,7 +92,7 @@ class ProgressBar * @param string $persistenceNamespace * @throws \Zend\ProgressBar\Exception When $min is greater than $max */ - public function __construct(Adapter\Adapter $adapter, $min = 0, $max = 100, $persistenceNamespace = null) + public function __construct(Adapter\AbstractAdapter $adapter, $min = 0, $max = 100, $persistenceNamespace = null) { // Check min/max values and set them if ($min > $max) { diff --git a/test/ProgressBarTest.php b/test/ProgressBarTest.php index 4afa72c..9d8b6cc 100644 --- a/test/ProgressBarTest.php +++ b/test/ProgressBarTest.php @@ -155,7 +155,7 @@ public function getText() } } -class MockUp extends \Zend\ProgressBar\Adapter\Adapter +class MockUp extends \Zend\ProgressBar\Adapter\AbstractAdapter { protected $_current; protected $_max;