Skip to content

Commit

Permalink
change property to protected
Browse files Browse the repository at this point in the history
  • Loading branch information
DyanGalih committed Apr 18, 2020
1 parent 5e9ec4d commit 361cd93
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 41 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/src/.DS_Store
./vendor/*
/.idea
/.idea
/vendor/
15 changes: 9 additions & 6 deletions src/Controllers/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,32 @@
use Illuminate\Routing\Controller;

/**
* @author: Dyan Galih<[email protected]> https://dyangalih.com
* @author: Dyan Galih<[email protected]>
* Date: 18/04/20
* Time: 18.55
* Class BaseController
* @package WebAppId\DDD\Controllers
*/
class BaseController extends Controller
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

/**
* @var Container
*/
private $container;
protected $container;

public function __construct(Container $container)
{
$this->container = $container;
}

/**
* @return Container
* @deprecated
*/
protected function getContainer()
{
return $this->container;
}
}
}
13 changes: 8 additions & 5 deletions src/Requests/AbstractFormRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
use Illuminate\Foundation\Http\FormRequest;

/**
* @author: Dyan Galih<[email protected]> https://dyangalih.com
* @author: Dyan Galih<[email protected]>
* Date: 18/04/20
* Time: 18.55
* Class AbstractFormRequest
* @package WebAppId\DDD\Requests
*/
abstract class AbstractFormRequest extends FormRequest implements FormRequestContract
{
Expand All @@ -22,25 +25,25 @@ public function authorize(): bool
{
return true;
}

/**
* @return mixed
*/
abstract function rules(): array;

/**
* @return array
*/
public function messages(): array
{
return [];
}

/**
* @return array
*/
public function attributes(): array
{
return [];
}
}
}
13 changes: 8 additions & 5 deletions src/Requests/FormRequestContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@
namespace WebAppId\DDD\Requests;

/**
* @author: Dyan Galih<[email protected]> https://dyangalih.com
* @author: Dyan Galih<[email protected]>
* Date: 18/04/20
* Time: 18.55
* Interface FormRequestContract
* @package WebAppId\DDD\Requests
*/
interface FormRequestContract
{
public function authorize(): bool;

public function rules(): array;

public function messages(): array;

public function attributes(): array;
}
}
26 changes: 17 additions & 9 deletions src/Responses/AbstractResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,57 +8,65 @@
namespace WebAppId\DDD\Responses;

/**
* @author: Dyan Galih<[email protected]> https://dyangalih.com
* @author: Dyan Galih<[email protected]>
* Date: 18/04/20
* Time: 18.55
* Class AbstractResponse
* @package WebAppId\DDD\Responses
*/
abstract class AbstractResponse
{
/**
* @var bool
*/
private $status;
protected $status;
/**
* @var string
*/
private $message;
protected $message;

/**
* @return bool
* @deprecated
*/
public function isStatus(): bool
{
return $this->status;
}

/**
* @return bool
* @deprecated
*/
public function getStatus(): bool
{
return $this->status;
}

/**
* @param bool $status
* @deprecated
*/
public function setStatus(bool $status): void
{
$this->status = $status;
}

/**
* @return string
* @deprecated
*/
public function getMessage(): string
{
return $this->message;
}

/**
* @param string $message
* @deprecated
*/
public function setMessage(string $message): void
{
$this->message = $message;
}
}
}
13 changes: 8 additions & 5 deletions src/Services/BaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@
use Illuminate\Container\Container;

/**
* @author: Dyan Galih<[email protected]> https://dyangalih.com
* @author: Dyan Galih<[email protected]>
* Date: 18/04/20
* Time: 18.55
* Class BaseService
* @package WebAppId\DDD\Services
*/
class BaseService
{
/**
* @var Container
*/
private $container;
protected $container;

/**
* BaseService constructor.
* @param Container $container
Expand All @@ -29,12 +32,12 @@ public function __construct(Container $container)
{
$this->container = $container;
}

/**
* @return Container
*/
protected function getContainer(): Container
{
return $this->container;
}
}
}
23 changes: 13 additions & 10 deletions src/Tools/PopoTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
use Illuminate\Database\Eloquent\Model;

/**
* @author: Dyan Galih<[email protected]> https://dyangalih.com
* @author: Dyan Galih<[email protected]>
* Date: 18/04/20
* Time: 18.56
* Class PopoTools
* @package WebAppId\DDD\Tools
*/
class PopoTools
{

/**
* @param mixed $object
* @return string|false
Expand All @@ -26,7 +29,7 @@ public function serializeJson($object)
{
return json_encode($this->serialize($object));
}

private function fixKey($key): string
{
if (stripos($key, "\0") === 0) {
Expand All @@ -36,17 +39,17 @@ private function fixKey($key): string
}
return $newKey;
}

/**
* @param $object
* @return array
*/
public function serialize($object)
{
$objectAsArray = (array)$object;

foreach ($objectAsArray as $key => $value) {

$newKey = $this->fixKey($key);
if ($newKey != $key) {
$this->replaceKey($objectAsArray, $key, $newKey);
Expand All @@ -71,10 +74,10 @@ public function serialize($object)
}
}
}

return $objectAsArray;
}

/**
* @param $array
* @param $curkey
Expand All @@ -88,10 +91,10 @@ function replaceKey(&$array, $curkey, $newkey)
unset($array[$curkey]);
return true;
}

return false;
}

/**
* @param string $oldKey
* @return string
Expand Down

0 comments on commit 361cd93

Please sign in to comment.