0

So I am fairly new to OOP PHP and Laravel. I am building a new package that will interface with other ticketing systems. I would like to implement the proper way of doing this by using an interface, repository, etc. However, part of doing the interface, I know that all of the classes that implement that interface need to have the same functions, etc.

What if you have a ticketing system that has an extra function that you want to implement. Can you do that, and should you do that?

For example Ticket System A:

function getTicket
function createTicket
function closeTicket
function deleteTicket

Ticket System B:

function getTicket
function createTicket
function closeTicket
function deleteTicket

function lockTicket                     <--- Extra 
function someotherspecialfunctionTicket <--- Extra function

Any direction on how this should be done would greatly be appreciated.

Thanks

ka_lin
  • 9,329
  • 6
  • 35
  • 56
James
  • 43
  • 5
  • Sure, you can do anything you want. You just have to code it the way you want. – aynber Feb 28 '20 at 14:23
  • A class can implement [multiple interfaces](https://stackoverflow.com/questions/9249832/interface-segregation-principle-program-to-an-interface/35382190#35382190) – ka_lin Feb 28 '20 at 14:23

1 Answers1

0

You can have the class private methods inside the specific class without sharing or forcing the class to implement them.

interface Iticket
{
     public function getTicket();
     public function createTicket();
     public function closeTicket();
     public function deleteTicket();
}

class TicketA implements Iticket
{
    public function getTicket(){
        // TODO Implementation
    }

    // .... Implemented all of the interface methods

    // Then you can implement Class private methods, without sharing it to the outside world
    private function lockTicket(){

    }

}

class TicketB implements Iticket
{

}
Mohammad.Kaab
  • 1,025
  • 7
  • 20
  • Thank you for the explanation. This makes sense to me now. I will try this out and see how it goes. – James Feb 28 '20 at 19:56