jeudi 27 septembre 2018

Refactor if statement with many or

How to refactor this conditions to make simpler and cleaner?

if(in_array($sides, [self::ALL_SIDES, self::HORIZONTAL_SIDES, self::LEFT_SIDE ])) {

}

if(in_array($sides, [self::ALL_SIDES, self::HORIZONTAL_SIDES, self::RIGHT_SIDE ])) {

}

if(in_array($sides, [self::ALL_SIDES, self::VERTICAL_SIDES, self::TOP_SIDE ])) {

}

if(in_array($sides, [self::ALL_SIDES, self::VERTICAL_SIDES, self::BOTTOM_SIDE ])) {

}

Aucun commentaire:

Enregistrer un commentaire