@@ 6-42 (lines=37) @@ | ||
3 | ||
4 | use Germania\VatIdNo\VatIdNoProviderInterface; |
|
5 | ||
6 | class WithoutTaxNoFilterIterator extends \FilterIterator |
|
7 | { |
|
8 | public $field = "taxno"; |
|
9 | ||
10 | public function __construct(\Traversable $iterator, $field = null) |
|
11 | { |
|
12 | if ($iterator instanceof \Iterator) { |
|
13 | parent::__construct($iterator); |
|
14 | } else { |
|
15 | parent::__construct($iterator->getIterator()); |
|
16 | } |
|
17 | ||
18 | $this->field = $field ?: $this->field; |
|
19 | } |
|
20 | ||
21 | ||
22 | public function accept() |
|
23 | { |
|
24 | $current = $this->getInnerIterator()->current(); |
|
25 | ||
26 | if ($current instanceof VatIdNoProviderInterface) { |
|
27 | return empty($current->getTaxNo()); |
|
28 | } elseif (is_array($current)) { |
|
29 | return !array_key_exists($this->field, $current) |
|
30 | or empty($current[ $this->field ]); |
|
31 | } elseif (is_object($current)) { |
|
32 | return !isset($current->{$this->field}) |
|
33 | or empty($current->{$this->field}); |
|
34 | } |
|
35 | ||
36 | return true; |
|
37 | } |
|
38 | } |
|
39 |
@@ 6-42 (lines=37) @@ | ||
3 | ||
4 | use Germania\VatIdNo\VatIdNoProviderInterface; |
|
5 | ||
6 | class WithoutVatIdNoFilterIterator extends \FilterIterator |
|
7 | { |
|
8 | public $field = "vatin"; |
|
9 | ||
10 | public function __construct(\Traversable $iterator, $field = null) |
|
11 | { |
|
12 | if ($iterator instanceof \Iterator) { |
|
13 | parent::__construct($iterator); |
|
14 | } else { |
|
15 | parent::__construct($iterator->getIterator()); |
|
16 | } |
|
17 | ||
18 | $this->field = $field ?: $this->field; |
|
19 | } |
|
20 | ||
21 | ||
22 | public function accept() |
|
23 | { |
|
24 | $current = $this->getInnerIterator()->current(); |
|
25 | ||
26 | if ($current instanceof VatIdNoProviderInterface) { |
|
27 | return empty($current->getVatIdNo()); |
|
28 | } elseif (is_array($current)) { |
|
29 | return !array_key_exists($this->field, $current) |
|
30 | or empty($current[ $this->field ]); |
|
31 | } elseif (is_object($current)) { |
|
32 | return !isset($current->{$this->field}) |
|
33 | or empty($current->{$this->field}); |
|
34 | } |
|
35 | return true; |
|
36 | } |
|
37 | } |
|
38 |
@@ 6-41 (lines=36) @@ | ||
3 | ||
4 | use Germania\VatIdNo\VatIdNoProviderInterface; |
|
5 | ||
6 | class WithTaxNoFilterIterator extends \FilterIterator |
|
7 | { |
|
8 | public $field = "taxno"; |
|
9 | ||
10 | public function __construct(\Traversable $iterator, $field = null) |
|
11 | { |
|
12 | if ($iterator instanceof \Iterator) { |
|
13 | parent::__construct($iterator); |
|
14 | } else { |
|
15 | parent::__construct($iterator->getIterator()); |
|
16 | } |
|
17 | ||
18 | $this->field = $field ?: $this->field; |
|
19 | } |
|
20 | ||
21 | public function accept() |
|
22 | { |
|
23 | $current = $this->getInnerIterator()->current(); |
|
24 | ||
25 | if ($current instanceof VatIdNoProviderInterface) { |
|
26 | return !empty($current->getTaxNo()); |
|
27 | } elseif (is_array($current)) { |
|
28 | return array_key_exists($this->field, $current) |
|
29 | and !empty($current[ $this->field ]); |
|
30 | } elseif (is_object($current)) { |
|
31 | return isset($current->{$this->field}) |
|
32 | and !empty($current->{$this->field}); |
|
33 | } |
|
34 | ||
35 | return false; |
|
36 | } |
|
37 | } |
|
38 |
@@ 6-41 (lines=36) @@ | ||
3 | ||
4 | use Germania\VatIdNo\VatIdNoProviderInterface; |
|
5 | ||
6 | class WithVatIdNoFilterIterator extends \FilterIterator |
|
7 | { |
|
8 | public $field = "vatin"; |
|
9 | ||
10 | public function __construct(\Traversable $iterator, $field = null) |
|
11 | { |
|
12 | if ($iterator instanceof \Iterator) { |
|
13 | parent::__construct($iterator); |
|
14 | } else { |
|
15 | parent::__construct($iterator->getIterator()); |
|
16 | } |
|
17 | ||
18 | $this->field = $field ?: $this->field; |
|
19 | } |
|
20 | ||
21 | public function accept() |
|
22 | { |
|
23 | $current = $this->getInnerIterator()->current(); |
|
24 | ||
25 | if ($current instanceof VatIdNoProviderInterface) { |
|
26 | return !empty($current->getVatIdNo()); |
|
27 | } elseif (is_array($current)) { |
|
28 | return array_key_exists($this->field, $current) |
|
29 | and !empty($current[ $this->field ]); |
|
30 | } elseif (is_object($current)) { |
|
31 | return isset($current->{$this->field}) |
|
32 | and !empty($current->{$this->field}); |
|
33 | } |
|
34 | return false; |
|
35 | } |
|
36 | } |
|
37 |