Skip to content

Commit 62f2b07

Browse files
author
Daniel Opitz
committed
Changed schema. Renamed result to data
1 parent 446d27d commit 62f2b07

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

src/Validation/ServiceResult.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ServiceResult implements JsonSerializable
2727
/**
2828
* @var mixed|null
2929
*/
30-
protected $result;
30+
protected $data;
3131

3232
/**
3333
* Get message.
@@ -102,13 +102,13 @@ public function setCode($code)
102102
}
103103

104104
/**
105-
* Returns the value that was being bound during model binding.
105+
* Returns the the document’s "primary data".
106106
*
107107
* @return mixed The result data
108108
*/
109-
public function getResult()
109+
public function getData()
110110
{
111-
return $this->result;
111+
return $this->data;
112112
}
113113

114114
/**
@@ -118,9 +118,9 @@ public function getResult()
118118
*
119119
* @return $this self
120120
*/
121-
public function setResult($result)
121+
public function setData($result)
122122
{
123-
$this->result = $result;
123+
$this->data = $result;
124124

125125
return $this;
126126
}
@@ -146,9 +146,9 @@ public function toArray(): array
146146
$data['code'] = $code;
147147
}
148148

149-
$result = $this->getResult();
149+
$result = $this->getData();
150150
if ($result !== null) {
151-
$data['result'] = $this->getResult();
151+
$data['data'] = $this->getData();
152152
}
153153

154154
return $data;

tests/ServiceResultTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ public function testCode()
4444
public function testResult()
4545
{
4646
$val = new ServiceResult();
47-
$actual = $val->getResult();
47+
$actual = $val->getData();
4848
$this->assertSame(null, $actual);
4949

50-
$val->setResult(['first_name' => 'max']);
51-
$resultText = $val->getResult();
50+
$val->setData(['first_name' => 'max']);
51+
$resultText = $val->getData();
5252
$this->assertSame(['first_name' => 'max'], $resultText);
5353
}
5454

@@ -67,8 +67,8 @@ public function testArray()
6767
$actual = $val->toArray();
6868
$this->assertSame(['success' => true, 'code' => '500'], $actual);
6969

70-
$val->setResult([]);
70+
$val->setData(['id' => 1]);
7171
$actual = $val->toArray();
72-
$this->assertSame(['success' => true, 'code' => '500', 'result' => []], $actual);
72+
$this->assertSame(['success' => true, 'code' => '500', 'data' => ['id' => 1]], $actual);
7373
}
7474
}

tests/TestService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function process(int $id): ServiceResult
3838
$result->setSuccess(true);
3939
$result->setMessage('Successfully');
4040
$result->setCode(0);
41-
$result->setResult(['foo' => 'value']);
41+
$result->setData(['foo' => 'value']);
4242

4343
return $result;
4444
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @coversDefaultClass \Odan\Validation\ValidationError
1212
*/
13-
class ValidationMessageTest extends TestCase
13+
class ValidationErrorTest extends TestCase
1414
{
1515
public function testConstruct()
1616
{

tests/ValidationExceptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function testSuccessAction()
2121
$result = $service->process(1);
2222
$json = $this->withJson($result);
2323

24-
$this->assertSame('{"success":true,"message":"Successfully","code":0,"result":{"foo":"value"}}', $json);
24+
$this->assertSame('{"success":true,"message":"Successfully","code":0,"data":{"foo":"value"}}', $json);
2525
}
2626

2727
/**

0 commit comments

Comments
 (0)