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

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 108 deletions.
14 changes: 0 additions & 14 deletions .travis/run-tests.sh

This file was deleted.

7 changes: 0 additions & 7 deletions .travis/skipped-components

This file was deleted.

61 changes: 0 additions & 61 deletions .travis/tested-components

This file was deleted.

36 changes: 18 additions & 18 deletions src/Word.php → src/AbstractWord.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use Zend\Session\Container;

/**
* Word-based captcha adapter
* AbstractWord-based captcha adapter
*
* Generates random word which user should recognise
*
Expand All @@ -34,7 +34,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
*/
abstract class Word extends AbstractAdapter
abstract class AbstractWord extends AbstractAdapter
{
/**#@+
* @var array Character sets
Expand Down Expand Up @@ -93,10 +93,10 @@ abstract class Word extends AbstractAdapter
* @var integer
*/
protected $timeout = 300;

/**
* Should generate() keep session or create a new one?
*
*
* @var boolean
*/
protected $keepSession = false;
Expand Down Expand Up @@ -140,7 +140,7 @@ public function getSessionClass()
* Set session class for persistence
*
* @param string $sessionClass
* @return Word
* @return AbstractWord
*/
public function setSessionClass($sessionClass)
{
Expand All @@ -162,7 +162,7 @@ public function getWordlen()
* Set word length of captcha
*
* @param integer $wordlen
* @return Word
* @return AbstractWord
*/
public function setWordlen($wordlen)
{
Expand Down Expand Up @@ -199,7 +199,7 @@ protected function setId ($id)
* Set timeout for session token
*
* @param int $ttl
* @return Word
* @return AbstractWord
*/
public function setTimeout($ttl)
{
Expand All @@ -219,19 +219,19 @@ public function getTimeout()

/**
* Sets if session should be preserved on generate()
*
*
* @param $keepSession Should session be kept on generate()?
* @return Word
* @return AbstractWord
*/
public function setKeepSession($keepSession)
public function setKeepSession($keepSession)
{
$this->keepSession = $keepSession;
return $this;
}

/**
* Numbers should be included in the pattern?
*
*
* @return bool
*/
public function getUseNumbers()
Expand All @@ -241,9 +241,9 @@ public function getUseNumbers()

/**
* Set if numbers should be included in the pattern
*
*
* @param bool $useNumbers numbers should be included in the pattern?
* @return Word
* @return AbstractWord
*/
public function setUseNumbers($useNumbers)
{
Expand Down Expand Up @@ -274,7 +274,7 @@ public function getSession()
* Set session namespace object
*
* @param Container $session
* @return Word
* @return AbstractWord
*/
public function setSession(Container $session)
{
Expand Down Expand Up @@ -303,7 +303,7 @@ public function getWord()
* Set captcha word
*
* @param string $word
* @return Word
* @return AbstractWord
*/
protected function setWord($word)
{
Expand Down Expand Up @@ -347,7 +347,7 @@ protected function generateWord()
public function generate()
{
if (!$this->keepSession) {
$this->session = null;
$this->session = null;
}
$id = $this->generateRandomId();
$this->setId($id);
Expand All @@ -358,7 +358,7 @@ public function generate()

/**
* Generate a random identifier
*
*
* @return void
*/
protected function generateRandomId()
Expand Down Expand Up @@ -417,6 +417,6 @@ public function isValid($value, $context = null)
*/
public function getHelperName()
{
return "captcha\word";
return 'captcha/word';
}
}
2 changes: 1 addition & 1 deletion src/Dumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,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
*/
class Dumb extends Word
class Dumb extends AbstractWord
{
/**
* CAPTCHA label
Expand Down
2 changes: 1 addition & 1 deletion src/Figlet.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,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
*/
class Figlet extends Word
class Figlet extends AbstractWord
{
/**
* Figlet text renderer
Expand Down
13 changes: 7 additions & 6 deletions src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
use DirectoryIterator;
use Zend\Captcha\Exception;
use Zend\Loader\Pluggable;
use Zend\Stdlib\ErrorException;
use Zend\Stdlib\ErrorHandler;

/**
Expand All @@ -38,7 +37,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
*/
class Image extends Word
class Image extends AbstractWord
{
/**
* Directory for generated images
Expand Down Expand Up @@ -492,7 +491,7 @@ protected function generateImage($id, $word)
$font = $this->getFont();

if (empty($font)) {
throw new Exception\NoFontProvidedException("Image CAPTCHA requires font");
throw new Exception\NoFontProvidedException('Image CAPTCHA requires font');
}

$w = $this->getWidth();
Expand All @@ -508,8 +507,10 @@ protected function generateImage($id, $word)
ErrorHandler::start();
$img = imagecreatefrompng($this->startImage);
$error = ErrorHandler::stop();
if (!$img || $error instanceof ErrorException) {
throw new Exception\ImageNotLoadableException("Can not load start image");
if (!$img || $error) {
throw new Exception\ImageNotLoadableException(
"Can not load start image '{$this->startImage}'", 0, $error
);
}
$w = imagesx($img);
$h = imagesy($img);
Expand Down Expand Up @@ -629,7 +630,7 @@ protected function gc()

/**
* Get helper name used to render captcha
*
*
* @return string
*/
public function getHelperName()
Expand Down

0 comments on commit b484733

Please sign in to comment.