Choosing a color based on exam score How can I simplify this code?

&lt;?php
class smth {
    protected static $MARK_UNDEFINED = 'Undefined';
    protected static $MARK_F  = 'ECTS-F';
    protected static $MARK_FX = 'ECTS-FX';
    protected static $MARK_E  = 'ECTS-E';
    protected static $MARK_D  = 'ECTS-D';
    protected static $MARK_C  = 'ECTS-C';
    protected static $MARK_B  = 'ECTS-B';
    protected static $MARK_A  = 'ECTS-A';

    protected function getECTSMark($rate, $current, $examRate)
    {
        $color = self::$MARK_UNDEFINED;
        if ($current &gt; 0) {
            $percent = $rate / $current;
            if ($examRate !== NULL AND $examRate &lt; 22)
                $color = self::$MARK_FX;
            elseif ($percent &lt; 0.31)
                $color = self::$MARK_F;
            elseif ($percent &lt; 0.60)
                $color = self::$MARK_FX;
            elseif ($percent &lt; 0.65)
                $color = self::$MARK_E;
            elseif ($percent &lt; 0.71)
                $color = self::$MARK_D;
            elseif ($percent &lt; 0.85)
                $color = self::$MARK_C;
            elseif ($percent &lt; 0.95)
                $color = self::$MARK_B;
            else
                $color = self::$MARK_A;
        }
        return $color;
    }
}
Note: I do not advocate this to be used, it is definitely wrong, untested, horrible and confusing.

But it should give you a start in using the associative array method that Alexander Kludt noted in his comment.

&lt;?php
class Smth 
{
    protected $marks = array(
        'Undefined' =&gt; 0, 'ECTS-F' =&gt; 0.31, 'ECTS-FX' =&gt; 0.60, 'ECTS-E' =&gt; 0.65, 
        'ECTS-D' 0.71, 'ECTS-C' =&gt; 0.85, 'ECTS-B' =&gt; 0.95, 'ECTS-A'
    );

    public function getEctsMark($rate, $current, $examRate) 
    {
        $color = reset($this-&gt;marks);
        $percent = $rate / $current;

        if($current &gt; 0 &amp;&amp; $examRate &lt; 22) {
            return "ECTS-FX";
        }

        /**
         * This is where the explanation is required. This *should* *maybe*
         * compare the percent to the current start band and the next band. So 
         * say for example the percent is 0.78(78%) this would foreach through 
         * the  marks array and eventually return true on &gt;= $percentStart(0.71)
         * and &lt;= the next band start up which is 0.85.
         */
        $i = 0;
        foreach($this-&gt;marks as $key =&gt; $percentStart) {
            if($percent &gt;= $percentStart &amp;&amp; $percentStart &lt;= $this-&gt;marks[$i+1]) {
                $color = $key;
                break;
            }           
            $i++;
        }

        return $color;
    }
}


If you are wanting feedback on your original code, I made a few changes which might satisfy your criteria of simplification over at this 3v4l.