Skip to content

Commit e3e1b53

Browse files
committed
Merge pull request #16 from robcaw/master
Code quality fixes
2 parents 38f0285 + 53e349e commit e3e1b53

3 files changed

Lines changed: 24 additions & 5 deletions

File tree

src/Vivait/StringGeneratorBundle/EventListener/GeneratorListener.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,33 @@ 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
/**
3635
* Registry has been made nullable as injecting it causes circular references. Instead, the container is injected
3736
* via a setter, and the registry is fetched from there instead.
3837
*
3938
* @param Reader $reader
40-
* @param Registry $registry
39+
* @param null|Registry $registry
4140
*/
4241
public function __construct(Reader $reader, Registry $registry = null)
4342
{
4443
$this->reader = $reader;
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,7 @@ private function generateString($property, GeneratorAnnotation $annotation, $obj
8890
{
8991
/** @var GeneratorInterface $generator */
9092
$generator = $this->getRegistry()->get($annotation->generator);
93+
9194
$generator->setLength($annotation->length);
9295

9396
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)