@@ -10,5 +10,5 @@ |
||
10 | 10 | * @var int|string $salesman_id |
11 | 11 | * @return self |
12 | 12 | */ |
13 | - public function setSalesmanId( $id ); |
|
13 | + public function setSalesmanId($id); |
|
14 | 14 | } |
@@ -15,8 +15,10 @@ |
||
15 | 15 | { |
16 | 16 | if ($salesman instanceOf SalesmanIdProviderInterface): |
17 | 17 | $this->salesman_id = $salesman->getSalesmanId(); |
18 | - else: |
|
18 | + else { |
|
19 | + : |
|
19 | 20 | $this->salesman_id = $salesman; |
21 | + } |
|
20 | 22 | endif; |
21 | 23 | |
22 | 24 | return $this; |
@@ -11,7 +11,7 @@ |
||
11 | 11 | * @var int|string|SalesmanIdProviderInterface $salesman |
12 | 12 | * @return self |
13 | 13 | */ |
14 | - public function setSalesmanId( $salesman ) |
|
14 | + public function setSalesmanId($salesman) |
|
15 | 15 | { |
16 | 16 | if ($salesman instanceOf SalesmanIdProviderInterface): |
17 | 17 | $this->salesman_id = $salesman->getSalesmanId(); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function getFullName() |
84 | 84 | { |
85 | - return trim( join(" ", array_filter([ |
|
85 | + return trim(join(" ", array_filter([ |
|
86 | 86 | $this->getFirstName(), |
87 | 87 | $this->getLastName() |
88 | 88 | ]))); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function getDisplayName() |
96 | 96 | { |
97 | - return trim( join(" ∙ ", array_filter([ |
|
97 | + return trim(join(" ∙ ", array_filter([ |
|
98 | 98 | $this->getFullName(), |
99 | 99 | $this->getSalesmanId() |
100 | 100 | ]))); |
@@ -50,8 +50,10 @@ |
||
50 | 50 | $aggregator->salesman = $salesman_factory( $aggregator->salesman_id, $this->salesman_fallback ); |
51 | 51 | |
52 | 52 | // Salesman can not be set |
53 | - else: |
|
53 | + else { |
|
54 | + : |
|
54 | 55 | return false; |
56 | + } |
|
55 | 57 | endif; |
56 | 58 | |
57 | 59 | return true; |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * @param callable $salesman_factory Callable that takes a Salesman ID that should return a SalesmanInterface instance. |
20 | 20 | */ |
21 | - public function __construct( callable $salesman_factory, SalesmanInterface $salesman_fallback = null ) |
|
21 | + public function __construct(callable $salesman_factory, SalesmanInterface $salesman_fallback = null) |
|
22 | 22 | { |
23 | 23 | $this->salesman_factory = $salesman_factory; |
24 | 24 | $this->salesman_fallback = $salesman_fallback; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param SalesmanIdProviderInterface|StdClass $aggregator Object that provides a salesman_id |
30 | 30 | * @return bool |
31 | 31 | */ |
32 | - public function __invoke( $aggregator ) |
|
32 | + public function __invoke($aggregator) |
|
33 | 33 | { |
34 | 34 | |
35 | 35 | |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | |
46 | 46 | // If salesman_id is available |
47 | 47 | if ($aggregator instanceOf SalesmanIdProviderInterface): |
48 | - $aggregator->salesman = $salesman_factory( $aggregator->getSalesmanId(), $this->salesman_fallback ); |
|
48 | + $aggregator->salesman = $salesman_factory($aggregator->getSalesmanId(), $this->salesman_fallback); |
|
49 | 49 | |
50 | 50 | elseif (isset($aggregator->salesman_id)): |
51 | - $aggregator->salesman = $salesman_factory( $aggregator->salesman_id, $this->salesman_fallback ); |
|
51 | + $aggregator->salesman = $salesman_factory($aggregator->salesman_id, $this->salesman_fallback); |
|
52 | 52 | |
53 | 53 | // Salesman can not be set |
54 | 54 | else: |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | * @param SalesmanInterface $salesman_fallback Optional SalesmanInterface fallback instance |
33 | 33 | * @param callable $apply Optional Callable that takes the current item on iteration. |
34 | 34 | */ |
35 | - public function __construct( callable $salesman_factory, SalesmanInterface $salesman_fallback = null, callable $apply = null ) |
|
35 | + public function __construct(callable $salesman_factory, SalesmanInterface $salesman_fallback = null, callable $apply = null) |
|
36 | 36 | { |
37 | 37 | $this->salesman_factory = $salesman_factory; |
38 | - $this->apply = $apply ?: new ApplySalesman( $salesman_factory, $salesman_fallback ); |
|
38 | + $this->apply = $apply ?: new ApplySalesman($salesman_factory, $salesman_fallback); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @see http://php.net/manual/de/function.iterator-apply.php |
46 | 46 | */ |
47 | - public function __invoke( \Traversable $iterator ) |
|
47 | + public function __invoke(\Traversable $iterator) |
|
48 | 48 | { |
49 | 49 | |
50 | 50 | $current = ($iterator instanceOf \IteratorAggregate) |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | // Perform |
55 | 55 | $apply = $this->apply; |
56 | - $apply( $current ); |
|
56 | + $apply($current); |
|
57 | 57 | |
58 | 58 | // Must return true for iterator_apply |
59 | 59 | return true; |
@@ -71,7 +71,7 @@ |
||
71 | 71 | |
72 | 72 | |
73 | 73 | /** |
74 | - * @return Iterator |
|
74 | + * @return \ArrayIterator |
|
75 | 75 | */ |
76 | 76 | public function getIterator() |
77 | 77 | { |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param string $table The table name to use |
34 | 34 | * @param SalesmanInterface|null $salesman Class or object template to work with |
35 | 35 | */ |
36 | - public function __construct (\PDO $pdo, $table, SalesmanInterface $salesman = null) |
|
36 | + public function __construct(\PDO $pdo, $table, SalesmanInterface $salesman = null) |
|
37 | 37 | { |
38 | 38 | $this->table = $table; |
39 | 39 | $this->pdo = $pdo; |
@@ -59,15 +59,15 @@ discard block |
||
59 | 59 | aussendienst_vorname ASC, |
60 | 60 | aussendienst_nummer ASC"; |
61 | 61 | |
62 | - $this->stmt = $pdo->prepare( $sql ); |
|
62 | + $this->stmt = $pdo->prepare($sql); |
|
63 | 63 | |
64 | - $this->stmt->setFetchMode( \PDO::FETCH_CLASS, $this->php_salesman_class ); |
|
64 | + $this->stmt->setFetchMode(\PDO::FETCH_CLASS, $this->php_salesman_class); |
|
65 | 65 | |
66 | 66 | if (!$this->stmt->execute()): |
67 | 67 | throw new SalesmanDatabaseException("PdoAllSalesmen: Could not execute SQL query"); |
68 | 68 | endif; |
69 | 69 | |
70 | - $this->salesmen = $this->stmt->fetchAll( \PDO::FETCH_UNIQUE); |
|
70 | + $this->salesmen = $this->stmt->fetchAll(\PDO::FETCH_UNIQUE); |
|
71 | 71 | |
72 | 72 | } |
73 | 73 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | /** |
87 | 87 | * @implements ContainerInterface |
88 | 88 | */ |
89 | - public function has ($aussendienst_nummer) { |
|
89 | + public function has($aussendienst_nummer) { |
|
90 | 90 | if ($aussendienst_nummer instanceOf SalesmanIdProviderInterface) { |
91 | 91 | $aussendienst_nummer = $aussendienst_nummer->getSalesmanId(); |
92 | 92 | } |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | /** |
98 | 98 | * @implements ContainerInterface |
99 | 99 | */ |
100 | - public function get ($aussendienst_nummer) { |
|
100 | + public function get($aussendienst_nummer) { |
|
101 | 101 | if ($aussendienst_nummer instanceOf SalesmanIdProviderInterface) { |
102 | 102 | $aussendienst_nummer = $aussendienst_nummer->getSalesmanId(); |
103 | 103 | } |
104 | 104 | |
105 | 105 | if (!$this->has($aussendienst_nummer)) { |
106 | 106 | $msg = sprintf("Could not find Salesman with ADM-Nummer '%s'", $aussendienst_nummer); |
107 | - throw new SalesmanNotFoundException( $msg ); |
|
107 | + throw new SalesmanNotFoundException($msg); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | return $this->salesmen[$aussendienst_nummer]; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function getIterator() |
118 | 118 | { |
119 | - return new \ArrayIterator( $this->salesmen ); |
|
119 | + return new \ArrayIterator($this->salesmen); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | |
@@ -125,6 +125,6 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function count() |
127 | 127 | { |
128 | - return count( $this->salesmen ); |
|
128 | + return count($this->salesmen); |
|
129 | 129 | } |
130 | 130 | } |
@@ -13,11 +13,11 @@ |
||
13 | 13 | * @param \Traversable $collection Collection of SalesmanIdProviderInterface |
14 | 14 | * @param bool $active_flag |
15 | 15 | */ |
16 | - public function __construct( \Traversable $collection, $active_flag = true ) |
|
16 | + public function __construct(\Traversable $collection, $active_flag = true) |
|
17 | 17 | { |
18 | 18 | // Take care of Traversable's two faces, |
19 | 19 | // since both IteratorAggregate and Iterator implement Traversable |
20 | - parent::__construct( $collection instanceOf \IteratorAggregate ? $collection->getIterator() : $collection ); |
|
20 | + parent::__construct($collection instanceOf \IteratorAggregate ? $collection->getIterator() : $collection); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | public function accept() |
@@ -4,13 +4,13 @@ |
||
4 | 4 | class PdoActiveSalesmen extends PdoAllSalesmen |
5 | 5 | { |
6 | 6 | |
7 | - public function __construct (\PDO $pdo, $table, SalesmanInterface $salesman = null) |
|
7 | + public function __construct(\PDO $pdo, $table, SalesmanInterface $salesman = null) |
|
8 | 8 | { |
9 | - parent::__construct( $pdo, $table, $salesman); |
|
9 | + parent::__construct($pdo, $table, $salesman); |
|
10 | 10 | |
11 | - $filtered = new ActiveSalesmanFilterIterator( $this->getIterator(), true); |
|
11 | + $filtered = new ActiveSalesmanFilterIterator($this->getIterator(), true); |
|
12 | 12 | |
13 | - $this->salesmen = iterator_to_array( $filtered ); |
|
13 | + $this->salesmen = iterator_to_array($filtered); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @param \Traversable $collection Collection of SalesmanIdProviderInterface |
15 | 15 | * @param SalesmanIdProviderInterface|SalesmanIdProviderInterface[]|int $salesman_filter The Salesman ID to filter for |
16 | 16 | */ |
17 | - public function __construct( \Traversable $collection, $salesman_filter ) |
|
17 | + public function __construct(\Traversable $collection, $salesman_filter) |
|
18 | 18 | { |
19 | 19 | // Allow for getSalesmanId |
20 | 20 | $this->salesman_filter = ($salesman_filter instanceOf SalesmanIdProviderInterface) |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | |
24 | 24 | // Cast to array |
25 | 25 | if (!is_array($this->salesman_filter)) { |
26 | - $this->salesman_filter = array( $this->salesman_filter ); |
|
26 | + $this->salesman_filter = array($this->salesman_filter); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | // Take care of Traversable's two faces, |
30 | 30 | // since both IteratorAggregate and Iterator implement Traversable |
31 | - parent::__construct( $collection instanceOf \IteratorAggregate ? $collection->getIterator() : $collection ); |
|
31 | + parent::__construct($collection instanceOf \IteratorAggregate ? $collection->getIterator() : $collection); |
|
32 | 32 | |
33 | 33 | } |
34 | 34 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | // Cast to array |
46 | 46 | $item_salesman_id = $item->getSalesmanId(); |
47 | 47 | if (!is_array($item_salesman_id)) { |
48 | - $item_salesman_id = array( $item_salesman_id ); |
|
48 | + $item_salesman_id = array($item_salesman_id); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | // Check intersection |