Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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);
}
}
<?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
You can’t perform that action at this time.