public static function countConsistentColumns(array $matrix, array $ignoreValues = [], $emptyIsConsistent = false)
    {
        $consistentCount = 0;
        
        if (!self::isValidMatrix($matrix)) {
            return $consistentCount;
        }
        
        for ($i = 0; $i < count($matrix[0]); $i++) {
            $column = array_column($matrix, $i);
            if (count($column) !== count($matrix)) {
                // Malformed matrix.
                return false;
            }
            
            $column = array_unique($column);
            
            foreach ($ignoreValues as $ignoreVal) {
                if (($search = array_search($ignoreVal, $column, true)) !== false) {
                    unset($column[$search]);
                }
            }
            
            if (count($column) === 1) {
                $consistentCount++;
            } elseif (count($column) === 0 && $emptyIsConsistent) {
                $consistentCount++;
            }
        }
        
        return $consistentCount;
    }