@@ 371-386 (lines=16) @@ | ||
368 | * |
|
369 | * @return mixed |
|
370 | */ |
|
371 | public function combine($values, $inPlace = false) |
|
372 | { |
|
373 | if (!is_array($values) && !($values instanceof Traversable)) { |
|
374 | $this->doThrow('Invalid input type for '.($inPlace ? 'replace' : 'combine').'.', $values); |
|
375 | } |
|
376 | ||
377 | if (count($values) != count($this->items)) { |
|
378 | $this->doThrow( |
|
379 | 'Invalid input for '.($inPlace ? 'replace' : 'combine').', number of items does not match.', |
|
380 | $values |
|
381 | ); |
|
382 | } |
|
383 | $values = Factory::getArrayForItems($values); |
|
384 | ||
385 | return Factory::create(array_combine($this->items, $values)); |
|
386 | } |
|
387 | ||
388 | /** |
|
389 | * Combine (in-place). |
@@ 62-78 (lines=17) @@ | ||
59 | /** |
|
60 | * {@inheritdoc} |
|
61 | */ |
|
62 | public function combine($values, $inPlace = false) |
|
63 | { |
|
64 | if (!is_array($values) && !($values instanceof Traversable)) { |
|
65 | $this->doThrow('Invalid input type for '.($inPlace ? 'replace' : 'combine').'.', $values); |
|
66 | } |
|
67 | ||
68 | // @todo This may change things performance-wise. I had to add this for Traversable $values to work - LV |
|
69 | $values = Factory::getArrayForItems($values); |
|
70 | if (count($values) != count($this->items)) { |
|
71 | $this->doThrow( |
|
72 | 'Invalid input for '.($inPlace ? 'replace' : 'combine').', number of items does not match.', |
|
73 | $values |
|
74 | ); |
|
75 | } |
|
76 | ||
77 | return Factory::create(array_combine($this->items, $values)); |
|
78 | } |
|
79 | ||
80 | /** |
|
81 | * {@inheritdoc} |