samedi 28 novembre 2020

Structure to define two class in PHP

I want to define two class and I am a little confused to choose the right structure. Among these two suggestion which one do you prefer ? and why?

Suggestion 1

<?php
    
    interface AbleToFly
    {
        public function fly();
    }
    
    abstract class Airplane implements AbleToFly
    {
    }
    
    abstract class Bird implements AbleToFly
    {
    }

Suggestion 2

<?php
    
    abstract class Airplain
    {
        public abstract function fly();
    }
    
    abstract class Bird extends Airplane
    {
    }

Thank you

Aucun commentaire:

Enregistrer un commentaire