Sunday, May 21, 2017

how should remove else blocks

PHPMD is telling me that I should avoid else block in this test, but in those case, I can't find a way to remove them.

Here is the code:

if ($fight->c1 == null) {
        if ($fight->c2 == null) {
            // C1 and C2 Is Bye
            $this->assertEquals($parentFight->$toUpdate, null);
        } else {
            // C1 Is Bye
            $this->assertEquals($parentFight->$toUpdate, $fight->c2);
        }
    } else {
        if ($fight->c2 == null) {
            // C2 Is Bye
            $this->assertEquals($parentFight->$toUpdate, $fight->c1);
        } else {
            // C1 and C2 Are all set
            $this->assertEquals($parentFight->$toUpdate, null);
        }
    }

Any Idea???



via Juliatzin del Toro

Advertisement