Skip to content

Commit

Permalink
remove 'code & message' in favor of 'messages'
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul M. Jones committed May 13, 2015
1 parent 616a352 commit 90ca6ff
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 54 deletions.
17 changes: 9 additions & 8 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,26 @@ Your domain layer should create a domain payload instance, call one or more of
the following methods, and return the payload object to the calling code. (Each
of these methods is optional.)

- `setStatus()`: Sets the payload status in terms of the domain layer; e.g.,
`success`, `failure`, and so on.

- `setInput()`: Sets the input as received by the domain layer.

- `setOutput()`: Sets the output produced by the domain layer.

- `setCode()`: Sets an error or status code reported by the domain layer.

- `setMessage()`: Sets an error or status message reported by the domain layer.
- `setMessages()`: Sets the messages reported by the domain layer.

- `setExtras()`: Sets "extra" values produced by the domain layer.
- `setExtras()`: Sets arbitrary "extra" values produced by the domain layer.

You calling code can then examine the payload object using the `get*()` complements
to the the `set*()` methods.

- `setStatus()`: Gets the payload status in terms of the domain layer.

- `getInput()`: Gets the input as received by the domain layer.

- `getOutput()`: Gets the output produced by the domain layer.

- `getCode()`: Gets an error or status code reported by the domain layer.

- `getMessage()`: Gets an error or status message reported by the domain layer.
- `getMessages()`: Gets the messages reported by the domain layer.

- `getExtras()`: Gets "extra" values produced by the domain layer.
- `getExtras()`: Gets arbitrary "extra" values produced by the domain layer.
30 changes: 6 additions & 24 deletions src/PayloadInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function setStatus($status);

/**
*
* Sets the status of this payload.
* Gets the status of this payload.
*
* @return mixed
*
Expand Down Expand Up @@ -73,39 +73,21 @@ public function getOutput();

/**
*
* Sets the error or status code produced by the domain layer.
*
* @param mixed $code The error or status code produced by the domain layer.
*
*/
public function setCode($code);

/**
*
* Gets the error or status code produced by the domain layer.
*
* @return mixed
*
*/
public function getCode();

/**
*
* Sets the error or status message produced by the domain layer.
* Sets the messages produced by the domain layer.
*
* @param mixed $message The error or status message produced by the domain layer.
* @param mixed $messages The messages produced by the domain layer.
*
*/
public function setMessage($message);
public function setMessages($messages);

/**
*
* Gets the error or status message produced by the domain layer.
* Gets the messages produced by the domain layer.
*
* @return mixed
*
*/
public function getMessage();
public function getMessages();

/**
*
Expand Down
22 changes: 5 additions & 17 deletions tests/Payload.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ class Payload implements PayloadInterface
protected $status;
protected $input;
protected $output;
protected $code;
protected $message;
protected $messages;
protected $extras;

public function setStatus($status)
Expand Down Expand Up @@ -43,26 +42,15 @@ public function getOutput()
return $this->output;
}

public function setCode($code)
public function setMessages($messages)
{
$this->code = $code;
$this->messages = $messages;
return $this;
}

public function getCode()
public function getMessages()
{
return $this->code;
}

public function setMessage($message)
{
$this->message = $message;
return $this;
}

public function getMessage()
{
return $this->message;
return $this->messages;
}

public function setExtras($extras)
Expand Down
9 changes: 4 additions & 5 deletions tests/PayloadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ public function test()
{
$payload = new Payload();

$payload->setStatus('status')
$payload
->setStatus('status')
->setInput('input')
->setOutput('output')
->setCode('code')
->setMessage('message')
->setMessages('messages')
->setExtras('extras');

$this->assertSame('status', $payload->getStatus());
$this->assertSame('input', $payload->getInput());
$this->assertSame('output', $payload->getOutput());
$this->assertSame('code', $payload->getCode());
$this->assertSame('message', $payload->getMessage());
$this->assertSame('messages', $payload->getMessages());
$this->assertSame('extras', $payload->getExtras());
}
}

0 comments on commit 90ca6ff

Please sign in to comment.