Skip to content

Commit

Permalink
Applied fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
butschster authored and StyleCIBot committed Nov 4, 2015
1 parent 9cf1925 commit 89e1791
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 123 deletions.
3 changes: 1 addition & 2 deletions src/Exceptions/AuthenticateException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

class AuthenticateException extends Exception
{

/**
* @var int
*/
protected $code = Response::ERROR_UNAUTHORIZED;
}
}
4 changes: 1 addition & 3 deletions src/Exceptions/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@

class Exception extends \RuntimeException
{

/**
* @var int
*/
protected $code = Response::ERROR_UNKNOWN;


/**
* @return array
*/
Expand All @@ -24,4 +22,4 @@ public function responseArray()
'message' => $this->getMessage(),
];
}
}
}
12 changes: 4 additions & 8 deletions src/Exceptions/MissingParameterException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

class MissingParameterException extends Exception
{

/**
* @var string
*/
Expand All @@ -16,21 +15,19 @@ class MissingParameterException extends Exception
/**
* @var array
*/
protected $rules = [ ];

protected $rules = [];

/**
* @param Validator $validator
*/
public function __construct(Validator $validator)
{
$this->rules = $validator->errors()->getMessages();
$this->rules = $validator->errors()->getMessages();
$this->message = trans('api.messages.missing_params', [
'field' => implode(', ', array_keys($validator->failed()))
'field' => implode(', ', array_keys($validator->failed())),
]);
}


/**
* @return array
*/
Expand All @@ -39,13 +36,12 @@ public function getFailedRules()
return $this->rules;
}


/**
* @return array
*/
public function responseArray()
{
$data = parent::responseArray();
$data = parent::responseArray();
$data['failed_rules'] = $this->getFailedRules();

return $data;
Expand Down
11 changes: 3 additions & 8 deletions src/Exceptions/PermissionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,21 @@

class PermissionException extends Exception
{

/**
* @var string
*/
protected $permission = '';


/**
* @param null $permission
* @param string $message
*/
public function __construct($permission = null, $message = "")
public function __construct($permission = null, $message = '')
{
$this->setPermission($permission);
$this->message = empty( $message ) ? trans('api.messages.error_permissions') : $message;
$this->message = empty($message) ? trans('api.messages.error_permissions') : $message;
}


/**
* @param $permission
*/
Expand All @@ -32,7 +29,6 @@ public function setPermission($permission)
$this->permission = $permission;
}


/**
* @return array
*/
Expand All @@ -41,8 +37,7 @@ public function responseArray()
return [
'code' => Response::ERROR_PERMISSIONS,
'type' => Response::TYPE_ERROR,
'permission' => $this->permission
'permission' => $this->permission,
];
}

}
17 changes: 5 additions & 12 deletions src/Exceptions/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,21 @@

class ValidationException extends Exception
{

/**
* @var array
*/
protected $messages = [ ];
protected $messages = [];

/**
* @var array
*/
protected $rules = [ ];
protected $rules = [];

/**
* @var int
*/
protected $code = Response::ERROR_VALIDATION;


/**
* @param Validator $object
*
Expand All @@ -32,41 +30,36 @@ class ValidationException extends Exception
public function setValidator(Validator $object)
{
$this->messages = $object->errors()->getMessages();
$this->rules = $object->failed();
$this->rules = $object->failed();

return $this;
}


/**
*
* @return array
*/
public function getFailedRules()
{
return $this->rules;
}


/**
*
* @return array
*/
public function getErrorMessages()
{
return $this->messages;
}


/**
* /**
* @return array
*/
public function responseArray()
{
$data = parent::responseArray();
$data = parent::responseArray();
$data['failed_rules'] = $this->getFailedRules();
$data['errors'] = $this->getErrorMessages();
$data['errors'] = $this->getErrorMessages();

return $data;
}
Expand Down
Loading

0 comments on commit 89e1791

Please sign in to comment.