/** * Constructs an array of Color objects by using $colorFactory to process * strings. Unrecognized strings are added to $invalidStrings. * * @param array $colorStrings * * @return array * An array of Color objects. */ private function buildColors(array $colorStrings) { $colors = array(); foreach ($colorStrings as $colorString) { if ($colorString instanceof Color) { $colors[(string) $colorString] = $colorString; continue; } $color = $this->colorFactory->buildColor($colorString); if (!empty($color)) { $colors[(string) $color] = $color; } else { $this->invalidStrings[] = (string) $colorString; } } return $colors; }