Skip to content
This repository has been archived by the owner on Jan 31, 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
3 parents 74e6fe9 + ba7b9a5 + cdbfce3 commit 6bf667a
Show file tree
Hide file tree
Showing 15 changed files with 355 additions and 304 deletions.
9 changes: 7 additions & 2 deletions src/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@
* @version $Id$
*/

/**
* @namespace
*/
namespace Zend\Text;

/**
* Exception class for Zend_Text
*
* @uses Zend_Exception
* @uses \Zend\Exception
* @category Zend
* @package Zend_Text
* @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_Text_Exception extends Zend_Exception
class Exception extends \Zend\Exception
{
}
9 changes: 7 additions & 2 deletions src/Figlet/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@
* @version $Id$
*/

/**
* @namespace
*/
namespace Zend\Text\Figlet;

/**
* Exception class for Zend_Figlet
*
* @uses Zend_Text_Exception
* @uses \Zend\Text\Exception
* @category Zend
* @package Zend_Text_Figlet
* @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_Text_Figlet_Exception extends Zend_Text_Exception
class Exception extends \Zend\Text\Exception
{
}
58 changes: 32 additions & 26 deletions src/Figlet.php → src/Figlet/Figlet.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,23 @@
* @version $Id$
*/

/**
* @namespace
*/
namespace Zend\Text\Figlet;
use Zend\Config;

/**
* Zend_Text_Figlet is a PHP implementation of FIGlet
*
* @uses InvalidArgumentException
* @uses Zend_Text_Figlet_Exception
* @uses \Zend\Text\Figlet\Exception
* @category Zend
* @package Zend_Text_Figlet
* @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_Text_Figlet
class Figlet
{
/**
* Smush2 layout modes
Expand Down Expand Up @@ -273,28 +279,28 @@ class Zend_Text_Figlet
* the $options variable, which can either be an array or an instance of
* Zend_Config.
*
* @param array|Zend_Config $options Options for the output
* @param array|\Zend\Config\Config $options Options for the output
*/
public function __construct($options = null)
{
// Set options
if (is_array($options)) {
$this->setOptions($options);
} else if ($options instanceof Zend_Config) {
} else if ($options instanceof Config\Config) {
$this->setConfig($options);
}

// If no font was defined, load default font
if (!$this->_fontLoaded) {
$this->_loadFont(dirname(__FILE__) . '/Figlet/zend-framework.flf');
$this->_loadFont(__DIR__ . '/zend-framework.flf');
}
}

/**
* Set options from array
*
* @param array $options Configuration for Zend_Text_Figlet
* @return Zend_Text_Figlet
* @param array $options Configuration for \Zend\Text\Figlet\Figlet
* @return \Zend\Text\Figlet\Figlet
*/
public function setOptions(array $options)
{
Expand All @@ -314,10 +320,10 @@ public function setOptions(array $options)
/**
* Set options from config object
*
* @param Zend_Config $config Configuration for Zend_Text_Figlet
* @return Zend_Text_Figlet
* @param Zend_Config $config Configuration for \Zend\Text\Figlet\Figlet
* @return \Zend\Text\Figlet\Figlet
*/
public function setConfig(Zend_Config $config)
public function setConfig(Config\Config $config)
{
return $this->setOptions($config->toArray());
}
Expand All @@ -326,7 +332,7 @@ public function setConfig(Zend_Config $config)
* Set a font to use
*
* @param string $font Path to the font
* @return Zend_Text_Figlet
* @return \Zend\Text\Figlet\Figlet
*/
public function setFont($font)
{
Expand All @@ -338,7 +344,7 @@ public function setFont($font)
* Set handling of paragraphs
*
* @param boolean $handleParagraphs Wether to handle paragraphs or not
* @return Zend_Text_Figlet
* @return \Zend\Text\Figlet\Figlet
*/
public function setHandleParagraphs($handleParagraphs)
{
Expand All @@ -351,7 +357,7 @@ public function setHandleParagraphs($handleParagraphs)
* for right aligned.
*
* @param integer $justification Justification of the output text
* @return Zend_Text_Figlet
* @return \Zend\Text\Figlet\Figlet
*/
public function setJustification($justification)
{
Expand All @@ -364,7 +370,7 @@ public function setJustification($justification)
*
* @param integer $outputWidth Output with which should be used for word
* wrapping and justification
* @return Zend_Text_Figlet
* @return \Zend\Text\Figlet\Figlet
*/
public function setOutputWidth($outputWidth)
{
Expand All @@ -378,7 +384,7 @@ public function setOutputWidth($outputWidth)
* use Zend_Text_Figlet::DIRECTION_RIGHT_TO_LEFT.
*
* @param integer $rightToLeft Right-to-left mode
* @return Zend_Text_Figlet
* @return \Zend\Text\Figlet\Figlet
*/
public function setRightToLeft($rightToLeft)
{
Expand All @@ -392,7 +398,7 @@ public function setRightToLeft($rightToLeft)
* Use one of the constants of Zend_Text_Figlet::SM_*, you may combine them.
*
* @param integer $smushMode Smush mode to use for generating text
* @return Zend_Text_Figlet
* @return \Zend\Text\Figlet\Figlet
*/
public function setSmushMode($smushMode)
{
Expand Down Expand Up @@ -423,13 +429,13 @@ public function setSmushMode($smushMode)
* @param string $text Text to convert to a figlet text
* @param string $encoding Encoding of the input string
* @throws InvalidArgumentException When $text is not a string
* @throws Zend_Text_Figlet_Exception When $text it not properly encoded
* @throws \Zend\Text\Figlet\Exception When $text it not properly encoded
* @return string
*/
public function render($text, $encoding = 'UTF-8')
{
if (!is_string($text)) {
throw new InvalidArgumentException('$text must be a string');
throw new \InvalidArgumentException('$text must be a string');
}

if ($encoding !== 'UTF-8') {
Expand All @@ -449,7 +455,7 @@ public function render($text, $encoding = 'UTF-8')
$textLength = @iconv_strlen($text, 'UTF-8');

if ($textLength === false) {
throw new Zend_Text_Figlet_Exception('$text is not encoded with ' . $encoding);
throw new Exception('$text is not encoded with ' . $encoding);
}

for ($charNum = 0; $charNum < $textLength; $charNum++) {
Expand Down Expand Up @@ -960,22 +966,22 @@ protected function _smushem($leftChar, $rightChar)
* Load the specified font
*
* @param string $fontFile Font file to load
* @throws Zend_Text_Figlet_Exception When font file was not found
* @throws Zend_Text_Figlet_Exception When GZIP library is required but not found
* @throws Zend_Text_Figlet_Exception When font file is not readable
* @throws \Zend\Text\Figlet\Exception When font file was not found
* @throws \Zend\Text\Figlet\Exception When GZIP library is required but not found
* @throws \Zend\Text\Figlet\Exception When font file is not readable
* @return void
*/
protected function _loadFont($fontFile)
{
// Check if the font file exists
if (!file_exists($fontFile)) {
throw new Zend_Text_Figlet_Exception($fontFile . ': Font file not found');
throw new Exception($fontFile . ': Font file not found');
}

// Check if gzip support is required
if (substr($fontFile, -3) === '.gz') {
if (!function_exists('gzcompress')) {
throw new Zend_Text_Figlet_Exception('GZIP library is required for '
throw new Exception('GZIP library is required for '
. 'gzip compressed font files');
}

Expand All @@ -988,7 +994,7 @@ protected function _loadFont($fontFile)
// Try to open the file
$fp = fopen($fontFile, 'rb');
if ($fp === false) {
throw new Zend_Text_Figlet_Exception($fontFile . ': Could not open file');
throw new Exception($fontFile . ': Could not open file');
}

// If the file is not compressed, lock the stream
Expand All @@ -1011,7 +1017,7 @@ protected function _loadFont($fontFile)
$this->_fontSmush);

if ($magic !== self::FONTFILE_MAGIC_NUMBER || $numsRead < 5) {
throw new Zend_Text_Figlet_Exception($fontFile . ': Not a FIGlet 2 font file');
throw new Exception($fontFile . ': Not a FIGlet 2 font file');
}

// Set default right to left
Expand Down
9 changes: 7 additions & 2 deletions src/MultiByte.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
* @version $Id$
*/

/**
* @namespace
*/
namespace Zend\Text;

/**
* Zend_Text_MultiByte contains multibyte safe string methods
*
Expand All @@ -27,7 +32,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 Zend_Text_MultiByte
class MultiByte
{
/**
* Word wrap
Expand Down Expand Up @@ -111,7 +116,7 @@ public static function wordWrap($string, $width = 75, $break = "\n", $cut = fals
* @param string $charset
* @return string
*/
public static function strPad($input, $padLength, $padString = ' ', $padType = STR_PAD_RIGHT, $charset = 'UTF-8')
public static function strPad($input, $padLength, $padString = ' ', $padType = \STR\PAD\RIGHT, $charset = 'UTF-8')
{
$return = '';
$lengthOfPadding = $padLength - iconv_strlen($input, $charset);
Expand Down
Loading

0 comments on commit 6bf667a

Please sign in to comment.