@@ -5,9 +5,9 @@ discard block |
||
5 | 5 | { |
6 | 6 | public $world_id; |
7 | 7 | |
8 | - public function __construct(\Traversable $iterator , WorldInterface $world) |
|
8 | + public function __construct(\Traversable $iterator, WorldInterface $world) |
|
9 | 9 | { |
10 | - parent::__construct( $iterator instanceOf \IteratorAggregate ? $iterator->getIterator() : $iterator); |
|
10 | + parent::__construct($iterator instanceOf \IteratorAggregate ? $iterator->getIterator() : $iterator); |
|
11 | 11 | |
12 | 12 | $this->world_id = $world->getId(); |
13 | 13 | } |
@@ -16,6 +16,6 @@ discard block |
||
16 | 16 | { |
17 | 17 | $current = $this->getInnerIterator()->current(); |
18 | 18 | return ($current instanceOf WorldsProviderInterface |
19 | - and $current->getWorlds()->has( $this->world_id )); |
|
19 | + and $current->getWorlds()->has($this->world_id)); |
|
20 | 20 | } |
21 | 21 | } |
@@ -4,5 +4,5 @@ |
||
4 | 4 | interface WorldsProviderInterface |
5 | 5 | { |
6 | 6 | public function getWorlds(); |
7 | - public function setWorlds( WorldsInterface $worlds); |
|
7 | + public function setWorlds(WorldsInterface $worlds); |
|
8 | 8 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @param WorldInterface|null $world WorldsInterface instance result template (optional) |
15 | 15 | * @param [type] $worlds_table Custom table name (optional) |
16 | 16 | */ |
17 | - public function __construct( \PDO $pdo, WorldInterface $world = null, $worlds_table = null ) |
|
17 | + public function __construct(\PDO $pdo, WorldInterface $world = null, $worlds_table = null) |
|
18 | 18 | { |
19 | 19 | $this->worlds = new \ArrayObject; |
20 | 20 | $this->worlds_table = $worlds_table ?: $this->worlds_table; |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | FROM {$this->worlds_table} |
32 | 32 | WHERE is_active > 0"; |
33 | 33 | |
34 | - $stmt = $pdo->prepare( $sql ); |
|
34 | + $stmt = $pdo->prepare($sql); |
|
35 | 35 | |
36 | - $stmt->setFetchMode( \PDO::FETCH_CLASS, $world ? get_class($world) : World::class ); |
|
36 | + $stmt->setFetchMode(\PDO::FETCH_CLASS, $world ? get_class($world) : World::class); |
|
37 | 37 | |
38 | 38 | if (!$stmt->execute()): |
39 | 39 | throw new DatabaseException("Could not retrieve Worlds from database"); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | public $worlds = array(); |
10 | 10 | |
11 | 11 | |
12 | - public function push( WorldInterface $world ) |
|
12 | + public function push(WorldInterface $world) |
|
13 | 13 | { |
14 | 14 | $this->worlds[ $world->getId() ] = $world; |
15 | 15 | return $this; |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | * @implements ContainerInterface |
20 | 20 | * @return WorldInterface |
21 | 21 | */ |
22 | - public function get( $id_or_slug ) |
|
22 | + public function get($id_or_slug) |
|
23 | 23 | { |
24 | - $filter = function( $world, $id ) use ($id_or_slug) { |
|
24 | + $filter = function($world, $id) use ($id_or_slug) { |
|
25 | 25 | return ($world->getId() == $id_or_slug |
26 | 26 | or $world->getSlug() == $id_or_slug); |
27 | 27 | }; |
28 | 28 | |
29 | - $worlds = new \CallbackFilterIterator( $this->getIterator(), $filter); |
|
29 | + $worlds = new \CallbackFilterIterator($this->getIterator(), $filter); |
|
30 | 30 | $worlds->rewind(); |
31 | 31 | if ($worlds->valid()): |
32 | 32 | return $worlds->current(); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @implements ContainerInterface |
42 | 42 | * @return boolean |
43 | 43 | */ |
44 | - public function has ($id_or_slug ) |
|
44 | + public function has($id_or_slug) |
|
45 | 45 | { |
46 | 46 | foreach ($this->worlds as $world) { |
47 | 47 | if ($world->getId() == $id_or_slug |
@@ -30,8 +30,10 @@ |
||
30 | 30 | $worlds->rewind(); |
31 | 31 | if ($worlds->valid()): |
32 | 32 | return $worlds->current(); |
33 | - else: |
|
33 | + else { |
|
34 | + : |
|
34 | 35 | throw new WorldNotFoundException("Could not find product world with ID or slug '$id_or_slug'"); |
36 | + } |
|
35 | 37 | endif; |
36 | 38 | } |
37 | 39 |
@@ -4,35 +4,35 @@ |
||
4 | 4 | class World extends WorldAbstract implements WorldInterface |
5 | 5 | { |
6 | 6 | |
7 | - public function setId( $id ) |
|
7 | + public function setId($id) |
|
8 | 8 | { |
9 | 9 | $this->id = $id; |
10 | 10 | return $this; |
11 | 11 | } |
12 | 12 | |
13 | 13 | |
14 | - public function setName( $name ) |
|
14 | + public function setName($name) |
|
15 | 15 | { |
16 | 16 | $this->name = $name; |
17 | 17 | return $this; |
18 | 18 | } |
19 | 19 | |
20 | 20 | |
21 | - public function setSlug( $slug ) |
|
21 | + public function setSlug($slug) |
|
22 | 22 | { |
23 | 23 | $this->slug = $slug; |
24 | 24 | return $this; |
25 | 25 | } |
26 | 26 | |
27 | 27 | |
28 | - public function setDescription( $description ) |
|
28 | + public function setDescription($description) |
|
29 | 29 | { |
30 | 30 | $this->description = $description; |
31 | 31 | return $this; |
32 | 32 | } |
33 | 33 | |
34 | 34 | |
35 | - public function setPhoto( $photo ) |
|
35 | + public function setPhoto($photo) |
|
36 | 36 | { |
37 | 37 | $this->photo = $photo; |
38 | 38 | return $this; |
@@ -5,5 +5,5 @@ |
||
5 | 5 | |
6 | 6 | interface WorldsInterface extends \IteratorAggregate, \Countable, ContainerInterface |
7 | 7 | { |
8 | - public function push( WorldInterface $world ); |
|
8 | + public function push(WorldInterface $world); |
|
9 | 9 | } |