Skip to content

Commit

Permalink
Исправлено форматирование кода. Код приведен к стандарту PSR-2
Browse files Browse the repository at this point in the history
  • Loading branch information
butschster committed Aug 27, 2015
1 parent 9ec10fc commit 41dd460
Show file tree
Hide file tree
Showing 10 changed files with 726 additions and 700 deletions.
36 changes: 18 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"name": "kodicms/laravel-api",
"license": "GNU GENERAL PUBLIC LICENSE",
"authors": [
{
"name": "Pavel Buchnev",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*"
},
"autoload": {
"psr-4": {
"KodiCMS\\API\\" : "src/"
}
},
"minimum-stability": "stable"
"name": "kodicms/laravel-api",
"license": "GNU GENERAL PUBLIC LICENSE",
"authors": [
{
"name": "Pavel Buchnev",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*"
},
"autoload": {
"psr-4": {
"KodiCMS\\API\\": "src/"
}
},
"minimum-stability": "stable"
}
8 changes: 4 additions & 4 deletions src/Exceptions/AuthenticateException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
class AuthenticateException extends Exception
{

/**
* @var int
*/
protected $code = Response::ERROR_UNAUTHORIZED;
/**
* @var int
*/
protected $code = Response::ERROR_UNAUTHORIZED;
}
30 changes: 15 additions & 15 deletions src/Exceptions/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
class Exception extends \RuntimeException
{

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


/**
* @return array
*/
public function responseArray()
{
return [
'code' => $this->getCode(),
'type' => Response::TYPE_ERROR,
'message' => $this->getMessage(),
];
}
/**
* @return array
*/
public function responseArray()
{
return [
'code' => $this->getCode(),
'type' => Response::TYPE_ERROR,
'message' => $this->getMessage(),
];
}
}
83 changes: 43 additions & 40 deletions src/Exceptions/MissingParameterException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,47 @@

class MissingParameterException extends Exception
{
/**
* @var string
*/
protected $code = Response::ERROR_MISSING_PAPAM;

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


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


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


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

return $data;
}

/**
* @var string
*/
protected $code = Response::ERROR_MISSING_PAPAM;

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


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


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


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

return $data;
}
}
74 changes: 37 additions & 37 deletions src/Exceptions/PermissionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@
class PermissionException extends Exception
{

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


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


/**
* @param $permission
*/
public function setPermission($permission)
{
$this->permission = $permission;
}


/**
* @return array
*/
public function responseArray()
{
return [
'code' => Response::ERROR_PERMISSIONS,
'type' => Response::TYPE_ERROR,
'permission' => $this->permission
];
}
/**
* @var string
*/
protected $permission = '';


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


/**
* @param $permission
*/
public function setPermission($permission)
{
$this->permission = $permission;
}


/**
* @return array
*/
public function responseArray()
{
return [
'code' => Response::ERROR_PERMISSIONS,
'type' => Response::TYPE_ERROR,
'permission' => $this->permission
];
}

}
126 changes: 63 additions & 63 deletions src/Exceptions/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,72 @@

namespace KodiCMS\API\Exceptions;

use Illuminate\Validation\Validator;
use KodiCMS\API\Http\Response;
use Illuminate\Validation\Validator;

class ValidationException extends Exception
{

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

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

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


/**
* @param Validator $object
*
* @return $this
*/
public function setValidator(Validator $object)
{
$this->messages = $object->errors()->getMessages();
$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['failed_rules'] = $this->getFailedRules();
$data['errors'] = $this->getErrorMessages();

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

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

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


/**
* @param Validator $object
*
* @return $this
*/
public function setValidator(Validator $object)
{
$this->messages = $object->errors()->getMessages();
$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['failed_rules'] = $this->getFailedRules();
$data['errors'] = $this->getErrorMessages();

return $data;
}
}
Loading

0 comments on commit 41dd460

Please sign in to comment.