Completed
Push — master ( a7a4b1...4dab2b )
by Shcherbak
25:32 queued 10:30
created

CombinedStringList   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 24
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A all() 0 3 1
1
<?php
2
3
  declare(strict_types=1);
4
5
  namespace Funivan\CabbageCore\String\StringList\Combined;
6
7
  use Funivan\CabbageCore\String\StringList\StringListInterface;
8
9
  class CombinedStringList implements StringListInterface {
10
11
    /**
12
     * @var string[]
13
     */
14
    private $values;
15
16
17
    public function __construct(StringListInterface ...$items) {
18
      $values = [];
19
      foreach ($items as $item) {
20
        $values = array_merge($values, iterator_to_array($item->all()));
21
      }
22
      $this->values = $values;
23
    }
24
25
26
    /**
27
     * @return string[]|\Generator
28
     */
29
    public function all(): \Generator {
30
      yield from $this->values;
31
    }
32
  }