class QualityGateEvaluator {

    public QualityGateStatus evaluate(final IssuesStatistics report, final FormattedLogger logger) {
        if (qualityGates.isEmpty()) {
            logger.print("-> INACTIVE - No quality gate defined");

            return QualityGateStatus.INACTIVE;
        }

        QualityGateStatus status = QualityGateStatus.PASSED;

        for (QualityGate qualityGate : qualityGates) {
            int actualSize = qualityGate.getActualSizeMethodReference().apply(report);
            if (actualSize >= qualityGate.getThreshold()) {
                logger.print("-> %s - %s: %d - Quality QualityGate: %d",
                        qualityGate.getStatus(), qualityGate.getName(), actualSize, qualityGate.getThreshold());
                if (qualityGate.getStatus().isWorseThan(status)) {
                    status = qualityGate.getStatus();
                }
            }
            else {
                logger.print("-> PASSED - %s: %d - Quality QualityGate: %d",
                        qualityGate.getName(), actualSize, qualityGate.getThreshold());
            }
        }

        return status;
    }

}