Created
October 15, 2019 15:28
-
-
Save shakkurcwb/22023b41902201b2fcb1d083831fd0ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Services; | |
use Illuminate\Support\Arr; | |
abstract class Service | |
{ | |
/** Parameters */ | |
private $parameters = []; | |
/** Attributes */ | |
private $attributes = []; | |
/** Constructor */ | |
public function __construct() | |
{ | |
// | |
} | |
/** Reset Service Properties */ | |
public function reset(): Void | |
{ | |
$this->parameters = []; | |
$this->attributes = []; | |
} | |
/** Set Parameters */ | |
public function setParameters(Array $parameters = []): Void | |
{ | |
$this->parameters = array_merge($this->parameters, $parameters); | |
} | |
/** Set Attributes */ | |
public function setAttributes(Array $attributes = []): Void | |
{ | |
$this->attributes = array_merge($this->attributes, $attributes); | |
} | |
/** Get Parameters */ | |
public function getParameters(String $key = "") | |
{ | |
if (!empty($key)) { | |
return Arr::get($this->parameters, $key); | |
} | |
return $this->parameters; | |
} | |
/** Get Attributes */ | |
public function getAttributes(String $key = "") | |
{ | |
if (!empty($key)) { | |
return Arr::get($this->attributes, $key); | |
} | |
return $this->attributes; | |
} | |
/** | |
* Adapter to report an exception. | |
* | |
* @param \Exception $e | |
* @return Void | |
*/ | |
public function report(\Exception $e): Void | |
{ | |
throw new \Exception($e); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Services; | |
interface ServiceContract | |
{ | |
/** Execute the Service */ | |
public function execute(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment