jeudi 2 février 2017

PHP - API Invoke Design Pattern

I have created multiple php classes to make returning data from a third party API clean and easy in my applications.

The classes essentially acts as layers, that depend on one another to perform a task.

class A {

    function Authenticate() {
        //get the required token
    }

    function invoke() {
        //call the API
    }
}


class B {

    function getName() {
        //calls the getName method in the API
    }


    function GetOrders() {
        //calls the getOrders method in the API
    }
}

class C {

    function getNamesAndOrdersByDateAsArray() {
        //call the getName and GetOrder in Class B and creates a date ordered array
    }
}

There are many ways in which the classes method can call each other. I'm hoping to get some thoughts on what would be considered the best design in this case.

Aucun commentaire:

Enregistrer un commentaire