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

Commit

Permalink
Show file tree
Hide file tree
Showing 25 changed files with 643 additions and 86 deletions.
6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
"php": ">=5.3.3",
"zendframework/zend-stdlib": "self.version"
},
"extra": {
"branch-alias": {
"dev-master": "2.2-dev",
"dev-develop": "2.3-dev"
}
},
"homepage": "https://github.com/zendframework/zend-progress-bar",
"autoload-dev": {
"psr-4": {
Expand Down
10 changes: 3 additions & 7 deletions src/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_ProgressBar
*/

namespace Zend\ProgressBar\Adapter;
Expand All @@ -15,9 +14,6 @@

/**
* Abstract class for Zend_ProgressBar_Adapters
*
* @category Zend
* @package Zend_ProgressBar
*/
abstract class AbstractAdapter
{
Expand Down Expand Up @@ -77,8 +73,8 @@ public function setOptions(array $options)
* @param float $current Current progress value
* @param float $max Max progress value
* @param float $percent Current percent value
* @param integer $timeTaken Taken time in seconds
* @param integer $timeRemaining Remaining time in seconds
* @param int $timeTaken Taken time in seconds
* @param int $timeRemaining Remaining time in seconds
* @param string $text Status text
* @return void
*/
Expand Down
38 changes: 21 additions & 17 deletions src/Adapter/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,19 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_ProgressBar
*/

namespace Zend\ProgressBar\Adapter;

use Zend\ProgressBar\Adapter\Exception;
use Zend\Stdlib\ErrorHandler;
use Zend\Stdlib\StringUtils;

/**
* Zend_ProgressBar_Adapter_Console offers a text-based progressbar for console
* applications
*
* @category Zend
* @package Zend_ProgressBar
*/
class Console extends AbstractAdapter
{
Expand Down Expand Up @@ -60,7 +57,7 @@ class Console extends AbstractAdapter
/**
* Width of the progressbar
*
* @var integer
* @var int
*/
protected $width = null;

Expand All @@ -69,9 +66,11 @@ class Console extends AbstractAdapter
*
* @var array
*/
protected $elements = array(self::ELEMENT_PERCENT,
self::ELEMENT_BAR,
self::ELEMENT_ETA);
protected $elements = array(
self::ELEMENT_PERCENT,
self::ELEMENT_BAR,
self::ELEMENT_ETA,
);

/**
* Which action to do at finish call
Expand All @@ -83,7 +82,7 @@ class Console extends AbstractAdapter
/**
* Width of the bar element
*
* @var integer
* @var int
*/
protected $barWidth;

Expand Down Expand Up @@ -125,7 +124,7 @@ class Console extends AbstractAdapter
/**
* Whether the output started yet or not
*
* @var boolean
* @var bool
*/
protected $outputStarted = false;

Expand Down Expand Up @@ -207,12 +206,12 @@ public function getOutputStream()
/**
* Set the width of the progressbar
*
* @param integer $width
* @param int $width
* @return \Zend\ProgressBar\Adapter\Console
*/
public function setWidth($width = null)
{
if ($width === null || !is_integer($width)) {
if ($width === null || !is_int($width)) {
if (substr(PHP_OS, 0, 3) === 'WIN') {
// We have to default to 79 on windows, because the windows
// terminal always has a fixed width of 80 characters and the
Expand Down Expand Up @@ -318,7 +317,7 @@ public function setBarIndicatorChar($char)
/**
* Set the width of the text element
*
* @param integer $width
* @param int $width
* @return \Zend\ProgressBar\Adapter\Console
*/
public function setTextWidth($width)
Expand Down Expand Up @@ -368,8 +367,8 @@ public function setFinishAction($action)
* @param float $current Current progress value
* @param float $max Max progress value
* @param float $percent Current percent value
* @param integer $timeTaken Taken time in seconds
* @param integer $timeRemaining Remaining time in seconds
* @param int $timeTaken Taken time in seconds
* @param int $timeRemaining Remaining time in seconds
* @param string $text Status text
* @return void
*/
Expand Down Expand Up @@ -438,7 +437,12 @@ 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[] = StringUtils::getWrapper($this->charset)->strPad(
substr($text, 0, $this->textWidth),
$this->textWidth,
' ',
STR_PAD_RIGHT
);
break;
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/Adapter/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_ProgressBar
*/

namespace Zend\ProgressBar\Adapter\Exception;
Expand All @@ -14,9 +13,6 @@

/**
* Exception class for Zend_ProgressBar_Adapter
*
* @category Zend
* @package Zend_ProgressBar
*/
interface ExceptionInterface extends ProgressBarException
{
Expand Down
6 changes: 1 addition & 5 deletions src/Adapter/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_ProgressBar
*/

namespace Zend\ProgressBar\Adapter\Exception;
Expand All @@ -14,9 +13,6 @@

/**
* Exception for Zend_Progressbar component.
*
* @category Zend
* @package Zend_ProgressBar
*/
class InvalidArgumentException extends Exception\InvalidArgumentException implements
ExceptionInterface
Expand Down
6 changes: 1 addition & 5 deletions src/Adapter/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_ProgressBar
*/

namespace Zend\ProgressBar\Adapter\Exception;
Expand All @@ -14,9 +13,6 @@

/**
* Exception for Zend_Progressbar component.
*
* @category Zend
* @package Zend_ProgressBar
*/
class RuntimeException extends Exception\RuntimeException implements
ExceptionInterface
Expand Down
14 changes: 5 additions & 9 deletions src/Adapter/JsPull.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_ProgressBar
*/

namespace Zend\ProgressBar\Adapter;
Expand All @@ -15,23 +14,20 @@
/**
* Zend_ProgressBar_Adapter_JsPull offers a simple method for updating a
* progressbar in a browser.
*
* @category Zend
* @package Zend_ProgressBar
*/
class JsPull extends AbstractAdapter
{
/**
* Whether to exit after json data send or not
*
* @var boolean
* @var bool
*/
protected $exitAfterSend = true;

/**
* Set whether to exit after json data send or not
*
* @param boolean $exitAfterSend
* @param bool $exitAfterSend
* @return \Zend\ProgressBar\Adapter\JsPull
*/
public function setExitAfterSend($exitAfterSend)
Expand All @@ -45,8 +41,8 @@ public function setExitAfterSend($exitAfterSend)
* @param float $current Current progress value
* @param float $max Max progress value
* @param float $percent Current percent value
* @param integer $timeTaken Taken time in seconds
* @param integer $timeRemaining Remaining time in seconds
* @param int $timeTaken Taken time in seconds
* @param int $timeRemaining Remaining time in seconds
* @param string $text Status text
* @return void
*/
Expand Down
10 changes: 3 additions & 7 deletions src/Adapter/JsPush.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_ProgressBar
*/

namespace Zend\ProgressBar\Adapter;
Expand All @@ -15,9 +14,6 @@
/**
* Zend_ProgressBar_Adapter_JsPush offers a simple method for updating a
* progressbar in a browser.
*
* @category Zend
* @package Zend_ProgressBar
*/
class JsPush extends AbstractAdapter
{
Expand Down Expand Up @@ -67,8 +63,8 @@ public function setFinishMethodName($methodName)
* @param float $current Current progress value
* @param float $max Max progress value
* @param float $percent Current percent value
* @param integer $timeTaken Taken time in seconds
* @param integer $timeRemaining Remaining time in seconds
* @param int $timeTaken Taken time in seconds
* @param int $timeRemaining Remaining time in seconds
* @param string $text Status text
* @return void
*/
Expand Down
6 changes: 1 addition & 5 deletions src/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_ProgressBar
*/

namespace Zend\ProgressBar\Exception;

/**
* Exception class for Zend_ProgressBar
*
* @category Zend
* @package Zend_ProgressBar
*/
interface ExceptionInterface
{
Expand Down
6 changes: 1 addition & 5 deletions src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_ProgressBar
*/

namespace Zend\ProgressBar\Exception;

/**
* Exception for Zend_Progressbar component.
*
* @category Zend
* @package Zend_ProgressBar
*/
class InvalidArgumentException extends \InvalidArgumentException implements
ExceptionInterface
Expand Down
6 changes: 1 addition & 5 deletions src/Exception/OutOfRangeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_ProgressBar
*/

namespace Zend\ProgressBar\Exception;

/**
* Exception for Zend_Progressbar component.
*
* @category Zend
* @package Zend_ProgressBar
*/
class OutOfRangeException extends \OutOfRangeException implements ExceptionInterface
{
Expand Down
13 changes: 13 additions & 0 deletions src/Exception/PhpEnvironmentException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\ProgressBar\Exception;

class PhpEnvironmentException extends RuntimeException
{}
6 changes: 1 addition & 5 deletions src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_ProgressBar
*/

namespace Zend\ProgressBar\Exception;

/**
* Exception for Zend_Progressbar component.
*
* @category Zend
* @package Zend_ProgressBar
*/
class RuntimeException extends \RuntimeException implements ExceptionInterface
{}
Loading

0 comments on commit 07035bd

Please sign in to comment.