fix (ECS) apply coding standard
This commit is contained in:
@ -7,12 +7,11 @@ namespace Gregwar\CaptchaBundle\Generator;
|
||||
use Gregwar\Captcha\CaptchaBuilder;
|
||||
use Gregwar\Captcha\PhraseBuilder;
|
||||
use Symfony\Component\Routing\RouterInterface;
|
||||
|
||||
use Gregwar\Captcha\CaptchaBuilderInterface;
|
||||
use Gregwar\Captcha\PhraseBuilderInterface;
|
||||
|
||||
/**
|
||||
* Uses configuration parameters to call the services that generate captcha images
|
||||
* Uses configuration parameters to call the services that generate captcha images.
|
||||
*
|
||||
* @author Gregwar <g.passault@gmail.com>
|
||||
* @author Jeremy Livingston <jeremy.j.livingston@gmail.com>
|
||||
@ -32,10 +31,10 @@ class CaptchaGenerator
|
||||
protected $imageFileHandler;
|
||||
|
||||
/**
|
||||
* @param RouterInterface $router
|
||||
* @param RouterInterface $router
|
||||
* @param CaptchaBuilderInterface $builder
|
||||
* @param PhraseBuilderInterface $phraseBuilder
|
||||
* @param ImageFileHandler $imageFileHandler
|
||||
* @param PhraseBuilderInterface $phraseBuilder
|
||||
* @param ImageFileHandler $imageFileHandler
|
||||
*/
|
||||
public function __construct(
|
||||
RouterInterface $router,
|
||||
@ -43,10 +42,10 @@ class CaptchaGenerator
|
||||
PhraseBuilderInterface $phraseBuilder,
|
||||
ImageFileHandler $imageFileHandler
|
||||
) {
|
||||
$this->router = $router;
|
||||
$this->builder = $builder;
|
||||
$this->phraseBuilder = $phraseBuilder;
|
||||
$this->imageFileHandler = $imageFileHandler;
|
||||
$this->router = $router;
|
||||
$this->builder = $builder;
|
||||
$this->phraseBuilder = $phraseBuilder;
|
||||
$this->imageFileHandler = $imageFileHandler;
|
||||
}
|
||||
|
||||
public function getCaptchaCode(array &$options): string
|
||||
@ -62,11 +61,13 @@ class CaptchaGenerator
|
||||
|
||||
// Returns the image generation URL
|
||||
if ($options['as_url']) {
|
||||
return $this->router->generate('gregwar_captcha.generate_captcha',
|
||||
array('key' => $options['session_key'], 'n' => md5(microtime(true).mt_rand())));
|
||||
return $this->router->generate(
|
||||
'gregwar_captcha.generate_captcha',
|
||||
array('key' => $options['session_key'], 'n' => md5(microtime(true).mt_rand()))
|
||||
);
|
||||
}
|
||||
|
||||
return 'data:image/jpeg;base64,' . base64_encode($this->generate($options));
|
||||
return 'data:image/jpeg;base64,'.base64_encode($this->generate($options));
|
||||
}
|
||||
|
||||
public function setPhrase(string $phrase): void
|
||||
@ -82,7 +83,7 @@ class CaptchaGenerator
|
||||
$this->builder->setMaxBehindLines($options['max_behind_lines']);
|
||||
|
||||
if (isset($options['text_color']) && $options['text_color']) {
|
||||
if (count($options['text_color']) !== 3) {
|
||||
if (3 !== count($options['text_color'])) {
|
||||
throw new \RuntimeException('text_color should be an array of r, g and b');
|
||||
}
|
||||
|
||||
@ -91,7 +92,7 @@ class CaptchaGenerator
|
||||
}
|
||||
|
||||
if (isset($options['background_color']) && $options['background_color']) {
|
||||
if (count($options['background_color']) !== 3) {
|
||||
if (3 !== count($options['background_color'])) {
|
||||
throw new \RuntimeException('background_color should be an array of r, g and b');
|
||||
}
|
||||
|
||||
@ -136,7 +137,7 @@ class CaptchaGenerator
|
||||
$phrase = $this->phraseBuilder->build($options['length'], $options['charset']);
|
||||
$options['phrase'] = $phrase;
|
||||
}
|
||||
|
||||
|
||||
return $phrase;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user