Permalink
Browse files

Abstract Response object and its subclass were created

  • Loading branch information...
AlexKupreev committed Jun 12, 2014
1 parent 3b52af1 commit 0d29b024aa6ef33679334c87bcf20b2dfebfa128
@@ -6,6 +6,7 @@
use app\repository as Repo;
use app\service as Service;
use app\request as Request;
use app\response as Response;
/**
* Task Creation Interactor
@@ -51,6 +52,9 @@ public function execute(Request\Task\Creation $request)
$request->getNotes()
);
return true;
$response = new Response\Task\Creation;
$response->setStatusOk();
return $response;
}
}
@@ -0,0 +1,13 @@
<?php
namespace app\response\Task;
use app\service as Service;
/**
* Response of Task Creation Interactor
*
*/
class Creation extends Service\Response {
}
View
@@ -0,0 +1,40 @@
<?php
namespace app\service;
/**
* Base Response class
*
*/
abstract class Response {
const OK = 200;
const ERROR_VALIDATION = 400;
const ERROR_ACCESS = 401;
const ERROR = 500;
/**
* Response status from available constants
* @var int
*/
protected $status = self::ERROR;
/**
* Detailed errors
* @var array
*/
protected $errorArray = [];
/**
* Set status as OK
*/
public function setStatusOk()
{
$this->status = self::OK;
}
public function isStatusOk()
{
return (bool)($this->status === self::OK);
}
}
@@ -104,7 +104,7 @@ public function iCreateATaskWithTheFollowingInformation(TableNode $table)
*/
public function taskShouldBeCreated()
{
Test::assertTrue($this->response);
Test::assertTrue($this->response->isStatusOk());
}
/**

0 comments on commit 0d29b02

Please sign in to comment.