From 52bd4542a9f07cd43329c13b32fce725f78ae0d0 Mon Sep 17 00:00:00 2001 From: Jaromir Tomek Date: Wed, 5 Apr 2023 14:23:57 +0200 Subject: [PATCH] Palette::findMaxPopulation() returns null for no swatches --- src/Palette.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Palette.php b/src/Palette.php index 4ea1d41..8b99d54 100644 --- a/src/Palette.php +++ b/src/Palette.php @@ -76,6 +76,9 @@ public function __construct($swatches) private function findMaxPopulation() { + if (!$this->swatches) { + return null; + } return max(array_map(function (Swatch $swatch) { return $swatch->getPopulation(); }, $this->swatches));