Skip to content

Commit 2bb72ac

Browse files
author
Robin Cawser
committed
Code quality fixes
1 parent 38dd184 commit 2bb72ac

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

src/Vivait/StringGeneratorBundle/EventListener/GeneratorListener.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,15 @@ class GeneratorListener
2020
* @var EntityRepository
2121
*/
2222
private $repo;
23-
/**
24-
* @var GeneratorInterface
25-
*/
26-
private $generator;
2723

2824
/**
2925
* @var Registry
3026
*/
3127
private $registry;
3228

29+
/**
30+
* @var ContainerInterface
31+
*/
3332
private $container;
3433

3534
/**
@@ -45,6 +44,9 @@ public function __construct(Reader $reader, Registry $registry = null)
4544
$this->registry = $registry;
4645
}
4746

47+
/**
48+
* @param ContainerInterface $container
49+
*/
4850
public function setContainer(ContainerInterface $container)
4951
{
5052
$this->container = $container;
@@ -88,6 +90,8 @@ private function generateString($property, GeneratorAnnotation $annotation, $obj
8890
{
8991
/** @var GeneratorInterface $generator */
9092
$generator = $this->getRegistry()->get($annotation->generator);
93+
94+
/** @noinspection PhpDeprecationInspection */
9195
$generator->setLength($annotation->length);
9296

9397
if(!empty($annotation->callbacks)){

src/Vivait/StringGeneratorBundle/Generator/SecureBytesGenerator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function __construct(SecureRandom $secureRandom)
2828
public function setLength($length)
2929
{
3030
$this->length = $length;
31+
return $this;
3132
}
3233

3334
/**

src/Vivait/StringGeneratorBundle/Registry/Registry.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ class Registry
1212
*/
1313
private $generators;
1414

15+
/**
16+
* @var ContainerInterface
17+
*/
18+
private $container;
19+
1520
/**
1621
* @param ContainerInterface $container
1722
* @param array $generators
@@ -22,6 +27,11 @@ function __construct(ContainerInterface $container, array $generators = [])
2227
$this->addAll($generators);
2328
}
2429

30+
/**
31+
* @param $field
32+
* @return GeneratorInterface
33+
* @throws \OutOfBoundsException
34+
*/
2535
public function get($field)
2636
{
2737
if (isset($this->generators[$field])) {
@@ -31,6 +41,11 @@ public function get($field)
3141
throw new \OutOfBoundsException(sprintf('Field "%s" not found in registry', $field));
3242
}
3343

44+
/**
45+
* @param $field
46+
* @param $class
47+
* @return $this
48+
*/
3449
public function add($field, $class)
3550
{
3651
$this->generators[$field] = $this->resolveGeneratorType($class);

0 commit comments

Comments
 (0)