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

Commit

Permalink
Merge branch 'git/namespace-pass3' into git/development-2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed May 27, 2010
2 parents 8fb5841 + b036c2a commit b288c81
Show file tree
Hide file tree
Showing 12 changed files with 380 additions and 160 deletions.
20 changes: 13 additions & 7 deletions src/Adapter.php → src/Adapter/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
* @version $Id$
*/

/**
* @namespace
*/
namespace Zend\ProgressBar\Adapter;
use Zend\Config;

/**
* Abstract class for Zend_ProgressBar_Adapters
*
Expand All @@ -27,7 +33,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 Zend_ProgressBar_Adapter
abstract class Adapter
{
/**
* Option keys to skip when calling setOptions()
Expand All @@ -45,24 +51,24 @@ abstract class Zend_ProgressBar_Adapter
* $options may be either be an array or a Zend_Config object which
* specifies adapter related options.
*
* @param null|array|Zend_Config $options
* @param null|array|\Zend\Config\Config $options
*/
public function __construct($options = null)
{
if (is_array($options)) {
$this->setOptions($options);
} elseif ($options instanceof Zend_Config) {
} elseif ($options instanceof Config\Config) {
$this->setConfig($options);
}
}

/**
* Set options via a Zend_Config instance
*
* @param Zend_Config $config
* @return Zend_ProgressBar_Adapter
* @param \Zend\Config\Config $config
* @return \Zend\ProgressBar\Adapter\Adapter
*/
public function setConfig(Zend_Config $config)
public function setConfig(Config\Config $config)
{
$this->setOptions($config->toArray());

Expand All @@ -73,7 +79,7 @@ public function setConfig(Zend_Config $config)
* Set options via an array
*
* @param array $options
* @return Zend_ProgressBar_Adapter
* @return \Zend\ProgressBar\Adapter\Adapter
*/
public function setOptions(array $options)
{
Expand Down
51 changes: 28 additions & 23 deletions src/Adapter/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,25 @@
* @version $Id$
*/

/**
* @namespace
*/
namespace Zend\ProgressBar\Adapter;

/**
* Zend_ProgressBar_Adapter_Console offers a text-based progressbar for console
* applications
*
* @uses Zend_ProgressBar_Adapter
* @uses Zend_ProgressBar_Adapter_Exception
* @uses Zend_Text_MultiByte
* @uses \Zend\ProgressBar\Adapter\Adapter
* @uses \Zend\ProgressBar\Adapter\Exception
* @uses \Zend\Text\MultiByte
* @category Zend
* @package Zend_ProgressBar
* @uses Zend_ProgressBar_Adapter_Interface
* @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 Zend_ProgressBar_Adapter_Console extends Zend_ProgressBar_Adapter
class Console extends Adapter
{
/**
* Percentage value of the progress
Expand Down Expand Up @@ -149,7 +154,7 @@ class Zend_ProgressBar_Adapter_Console extends Zend_ProgressBar_Adapter
/**
* Defined by Zend_ProgressBar_Adapter
*
* @param null|array|Zend_Config $options
* @param null|array|\Zend\Config\Config $options
*/
public function __construct($options = null)
{
Expand All @@ -176,14 +181,14 @@ public function __destruct()
* Set a different output-stream
*
* @param string $resource
* @return Zend_ProgressBar_Adapter_Console
* @return \Zend\ProgressBar\Adapter\Console
*/
public function setOutputStream($resource)
{
$stream = @fopen($resource, 'w');

if ($stream === false) {
throw new Zend_ProgressBar_Adapter_Exception('Unable to open stream');
throw new Exception('Unable to open stream');
}

if ($this->_outputStream !== null) {
Expand Down Expand Up @@ -215,7 +220,7 @@ public function getOutputStream()
* Set the width of the progressbar
*
* @param integer $width
* @return Zend_ProgressBar_Adapter_Console
* @return \Zend\ProgressBar\Adapter\Console
*/
public function setWidth($width = null)
{
Expand Down Expand Up @@ -250,8 +255,8 @@ public function setWidth($width = null)
* Set the elements to display with the progressbar
*
* @param array $elements
* @throws Zend_ProgressBar_Adapter_Exception When an invalid element is foudn in the array
* @return Zend_ProgressBar_Adapter_Console
* @throws \Zend\ProgressBar\Adapter\Exception When an invalid element is foudn in the array
* @return \Zend\ProgressBar\Adapter\Console
*/
public function setElements(array $elements)
{
Expand All @@ -261,7 +266,7 @@ public function setElements(array $elements)
self::ELEMENT_TEXT);

if (count(array_diff($elements, $allowedElements)) > 0) {
throw new Zend_ProgressBar_Adapter_Exception('Invalid element found in $elements array');
throw new Exception('Invalid element found in $elements array');
}

$this->_elements = $elements;
Expand All @@ -275,13 +280,13 @@ public function setElements(array $elements)
* Set the left-hand character for the bar
*
* @param string $char
* @throws Zend_ProgressBar_Adapter_Exception When character is empty
* @return Zend_ProgressBar_Adapter_Console
* @throws \Zend\ProgressBar\Adapter\Exception When character is empty
* @return \Zend\ProgressBar\Adapter\Console
*/
public function setBarLeftChar($char)
{
if (empty($char)) {
throw new Zend_ProgressBar_Adapter_Exception('Character may not be empty');
throw new Exception('Character may not be empty');
}

$this->_barLeftChar = (string) $char;
Expand All @@ -293,13 +298,13 @@ public function setBarLeftChar($char)
* Set the right-hand character for the bar
*
* @param string $char
* @throws Zend_ProgressBar_Adapter_Exception When character is empty
* @return Zend_ProgressBar_Adapter_Console
* @throws \Zend\ProgressBar\Adapter\Exception When character is empty
* @return \Zend\ProgressBar\Adapter\Console
*/
public function setBarRightChar($char)
{
if (empty($char)) {
throw new Zend_ProgressBar_Adapter_Exception('Character may not be empty');
throw new Exception('Character may not be empty');
}

$this->_barRightChar = (string) $char;
Expand All @@ -311,7 +316,7 @@ public function setBarRightChar($char)
* Set the indicator character for the bar
*
* @param string $char
* @return Zend_ProgressBar_Adapter_Console
* @return \Zend\ProgressBar\Adapter\Console
*/
public function setBarIndicatorChar($char)
{
Expand All @@ -324,7 +329,7 @@ public function setBarIndicatorChar($char)
* Set the width of the text element
*
* @param integer $width
* @return Zend_ProgressBar_Adapter_Console
* @return \Zend\ProgressBar\Adapter\Console
*/
public function setTextWidth($width)
{
Expand All @@ -349,8 +354,8 @@ public function setCharset($charset)
* Set the finish action
*
* @param string $action
* @throws Zend_ProgressBar_Adapter_Exception When an invalid action is specified
* @return Zend_ProgressBar_Adapter_Console
* @throws \Zend\ProgressBar\Adapter\Exception When an invalid action is specified
* @return \Zend\ProgressBar\Adapter\Console
*/
public function setFinishAction($action)
{
Expand All @@ -359,7 +364,7 @@ public function setFinishAction($action)
self::FINISH_ACTION_NONE);

if (!in_array($action, $allowedActions)) {
throw new Zend_ProgressBar_Adapter_Exception('Invalid finish action specified');
throw new Exception('Invalid finish action specified');
}

$this->_finishAction = $action;
Expand Down Expand Up @@ -443,7 +448,7 @@ public function notify($current, $max, $percent, $timeTaken, $timeRemaining, $te
break;

case self::ELEMENT_TEXT:
$renderedElements[] = Zend_Text_MultiByte::strPad(substr($text, 0, $this->_textWidth), $this->_textWidth, ' ', STR_PAD_RIGHT, $this->_charset);
$renderedElements[] = \Zend\Text\MultiByte::strPad(substr($text, 0, $this->_textWidth), $this->_textWidth, ' ', STR_PAD_RIGHT, $this->_charset);
break;
}
}
Expand Down
11 changes: 8 additions & 3 deletions src/Adapter/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@
* @version $Id$
*/

/**
* @namespace
*/
namespace Zend\ProgressBar\Adapter;

/**
* Exception class for Zend_ProgressBar_Adapter
*
* @uses Zend_ProgressBar_Exception
* @uses \Zend\ProgressBar\Exception
* @category Zend
* @package Zend_ProgressBar
* @uses Zend_ProgressBar_Exception
* @uses \Zend\ProgressBar\Exception
* @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 Zend_ProgressBar_Adapter_Exception extends Zend_ProgressBar_Exception
class Exception extends \Zend\ProgressBar\Exception
{
}
18 changes: 12 additions & 6 deletions src/Adapter/JsPull.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,25 @@
* @version $Id$
*/

/**
* @namespace
*/
namespace Zend\ProgressBar\Adapter;
use Zend\Json;

/**
* Zend_ProgressBar_Adapter_JsPull offers a simple method for updating a
* progressbar in a browser.
*
* @uses Zend_Json
* @uses Zend_ProgressBar_Adapter
* @uses \Zend\Json\Json
* @uses \Zend\ProgressBar\Adapter\Adapter
* @category Zend
* @package Zend_ProgressBar
* @uses Zend_ProgressBar_Adapter_Interface
* @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 Zend_ProgressBar_Adapter_JsPull extends Zend_ProgressBar_Adapter
class JsPull extends Adapter
{
/**
* Wether to exit after json data send or not
Expand All @@ -42,7 +48,7 @@ class Zend_ProgressBar_Adapter_JsPull extends Zend_ProgressBar_Adapter
* Set wether to exit after json data send or not
*
* @param boolean $exitAfterSend
* @return Zend_ProgressBar_Adapter_JsPull
* @return \Zend\ProgressBar\Adapter\JsPull
*/
public function setExitAfterSend($exitAfterSend)
{
Expand Down Expand Up @@ -72,7 +78,7 @@ public function notify($current, $max, $percent, $timeTaken, $timeRemaining, $te
'finished' => false
);

$data = Zend_Json::encode($arguments);
$data = Json\Json::encode($arguments);

// Output the data
$this->_outputData($data);
Expand All @@ -85,7 +91,7 @@ public function notify($current, $max, $percent, $timeTaken, $timeRemaining, $te
*/
public function finish()
{
$data = Zend_Json::encode(array('finished' => true));
$data = Json\Json::encode(array('finished' => true));

$this->_outputData($data);
}
Expand Down
19 changes: 12 additions & 7 deletions src/Adapter/JsPush.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,31 @@
* @version $Id$
*/

/**
* @namespace
*/
namespace Zend\ProgressBar\Adapter;

/**
* Zend_ProgressBar_Adapter_JsPush offers a simple method for updating a
* progressbar in a browser.
*
* @uses Zend_Json
* @uses Zend_ProgressBar_Adapter
* @uses \Zend\Json\Json
* @uses \Zend\ProgressBar\Adapter\Adapter
* @category Zend
* @package Zend_ProgressBar
* @uses Zend_ProgressBar_Adapter_Interface
* @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 Zend_ProgressBar_Adapter_JsPush extends Zend_ProgressBar_Adapter
class JsPush extends Adapter
{
/**
* Name of the JavaScript method to call on update
*
* @var string
*/
protected $_updateMethodName = 'Zend_ProgressBar_Update';
protected $_updateMethodName = 'Zend\ProgressBar\ProgressBar\Update';

/**
* Name of the JavaScript method to call on finish
Expand All @@ -49,7 +54,7 @@ class Zend_ProgressBar_Adapter_JsPush extends Zend_ProgressBar_Adapter
* Set the update method name
*
* @param string $methodName
* @return Zend_ProgressBar_Adapter_JsPush
* @return \Zend\ProgressBar\Adapter\JsPush
*/
public function setUpdateMethodName($methodName)
{
Expand All @@ -62,7 +67,7 @@ public function setUpdateMethodName($methodName)
* Set the finish method name
*
* @param string $methodName
* @return Zend_ProgressBar_Adapter_JsPush
* @return \Zend\ProgressBar\Adapter\JsPush
*/
public function setFinishMethodName($methodName)
{
Expand Down Expand Up @@ -94,7 +99,7 @@ public function notify($current, $max, $percent, $timeTaken, $timeRemaining, $te
);

$data = '<script type="text/javascript">'
. 'parent.' . $this->_updateMethodName . '(' . Zend_Json::encode($arguments) . ');'
. 'parent.' . $this->_updateMethodName . '(' . \Zend\Json\Json::encode($arguments) . ');'
. '</script>';

// Output the data
Expand Down
11 changes: 8 additions & 3 deletions src/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@
* @version $Id$
*/

/**
* @namespace
*/
namespace Zend\ProgressBar;

/**
* Exception class for Zend_ProgressBar
*
* @uses Zend_Exception
* @uses \Zend\Exception
* @category Zend
* @package Zend_ProgressBar
* @uses Zend_Exception
* @uses \Zend\Exception
* @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 Zend_ProgressBar_Exception extends Zend_Exception
class Exception extends \Zend\Exception
{
}
Loading

0 comments on commit b288c81

Please sign in to comment.