protected function createVariances(Palette $palette_1, Palette $palette_2) { $colors_1 = $palette_1->colors()->get(); $colors_2 = $palette_2->colors()->get(); // Does each palette contain the same number of colors if (count($colors_1) !== count($colors_2)) { trigger_error(__CLASS__ . " requires both Palette objects to contain the same number of colors", E_USER_WARNING); } // Loop through palettes and compare each colors based on a matching index for ($i = 0; $i < count($colors_1); $i++) { $this->variances[$i] = $colors_1[$i]->compareTo($colors_2[$i])->getVariance(); $this->rgbas[$i] = $colors_1[$i]->getRgba(); } return $this; }