Skip to content

Instantly share code, notes, and snippets.

@DarkGhostHunter
Last active November 17, 2019 19:46
Show Gist options
  • Save DarkGhostHunter/30c6ba1ca9d8eb4ca35c3cf38c58205a to your computer and use it in GitHub Desktop.
Save DarkGhostHunter/30c6ba1ca9d8eb4ca35c3cf38c58205a to your computer and use it in GitHub Desktop.
An example about using the Manager abstract class that comes with Laravel.
<?php
namespace App\Managers;
use App\Transport\Car\Car;
use App\Transport\Car\CarWheels;
use App\Transport\Car\FuelEngine;
use App\Transport\Car\Chassis;
use App\Transport\Bicycle\Bicycle;
use App\Transport\Bicycle\BicycleWheel;
use App\Transport\Bicycle\Pedals;
use App\Transport\Bicycle\Frame;
use App\Transport\StoreWithdrawal\StoreWithdrawal;
use Illuminate\Support\Manager;
class TransportManager extends Manager
{
/**
* Get the default driver name.
*
* @return string
*/
public function getDefaultDriver()
{
return 'bicycle';
}
/**
* Creates a new Car driver
*
* @return \App\Transport\Car\Car
*/
public function createCarDriver()
{
return new Car(new CarWheels, new FuelEngine, new Chassis);
}
/**
* Creates a new Bicycle driver
*
* @return \App\Transport\Bicycle\Bicycle
*/
public function createBicycleDriver()
{
return new Bicycle(new BicycleWheel, new Pedals, new Frame);
}
/**
* Creates a new Store Withdrawal driver
*
* @return \App\Transport\StoreWithdrawal\StoreWithdrawal
*/
public function createStoreWithdrawalDriver()
{
return new StoreWithdrawal;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment