private function getColor(array $notes, $noteIndex)
    {
        if (!is_integer($noteIndex) || !array_key_exists($noteIndex, $notes)) {
            return null;
        }

        $noteObj = $notes[$noteIndex];
        if (!is_object($noteObj) || !property_exists($noteObj, 'color')) {
            return null;
        }

        return $noteObj->color;
    }