Skip to content

Commit 66cee30

Browse files
committed
implement composer package PhpRestfulApiResponse
1 parent c2b9ac7 commit 66cee30

File tree

4 files changed

+66
-496
lines changed

4 files changed

+66
-496
lines changed

composer.json

+9-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"symfony/console": "^3.3",
1616
"league/fractal": "^0.17.0",
1717
"phpcollection/phpcollection": "^0.5.0",
18-
"zendframework/zend-diactoros": "^1.7"
18+
"zendframework/zend-diactoros": "^1.7",
19+
"harryosmar/php-restful-api-response": "^1.0"
1920
},
2021
"require-dev": {
2122
"fzaninotto/faker": "~1.4",
@@ -34,5 +35,11 @@
3435
},
3536
"scripts": {
3637
"test": "./vendor/bin/phpunit -c phpunit.xml"
37-
}
38+
},
39+
"repositories": [
40+
{
41+
"type": "vcs",
42+
"url": "git@github.com:harryosmar/php-restful-api-response.git"
43+
}
44+
]
3845
}

composer.lock

+54-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Contracts/Response.php

+2-124
Original file line numberDiff line numberDiff line change
@@ -8,131 +8,9 @@
88

99
namespace PhpBootstrap\Contracts;
1010

11-
use League\Fractal\Pagination\Cursor;
12-
use League\Fractal\TransformerAbstract;
13-
use Psr\Http\Message\ResponseInterface;
11+
use PhpRestfulApiResponse\Contracts\PhpRestfulApiResponse;
1412

15-
interface Response extends ResponseInterface
13+
interface Response extends PhpRestfulApiResponse
1614
{
17-
/**
18-
* @param $data
19-
* @param $code
20-
* @param array $headers
21-
* @return Response|static
22-
*/
23-
public function withArray(array $data, $code = 200, array $headers = []);
2415

25-
/**
26-
* @param $data
27-
* @param TransformerAbstract|callable $transformer
28-
* @param int $code
29-
* @param null $resourceKey
30-
* @param array $meta
31-
* @param array $headers
32-
* @return Response
33-
*/
34-
public function withItem($data, $transformer, $code = 200, $resourceKey = null, $meta = [], array $headers = []);
35-
36-
/**
37-
* @param $data
38-
* @param TransformerAbstract|callable $transformer
39-
* @param int $code
40-
* @param null $resourceKey
41-
* @param Cursor|null $cursor
42-
* @param array $meta
43-
* @param array $headers
44-
* @return Response
45-
*/
46-
public function withCollection($data, $transformer, $code = 200, $resourceKey = null, Cursor $cursor = null, $meta = [], array $headers = []);
47-
48-
/**
49-
* Generates a response with custom code HTTP header and a given message.
50-
*
51-
* @param $message
52-
* @param $code
53-
* @param array $headers
54-
* @return mixed
55-
*/
56-
public function withError($message, $code, array $headers = []);
57-
58-
/**
59-
* Generates a response with a 403 HTTP header and a given message.
60-
*
61-
* @param string $message
62-
* @param array $headers
63-
* @return mixed
64-
*/
65-
public function errorForbidden($message = '', array $headers = []);
66-
67-
/**
68-
* Generates a response with a 500 HTTP header and a given message.
69-
*
70-
* @param string $message
71-
* @param array $headers
72-
* @return mixed
73-
*/
74-
public function errorInternalError($message = '', array $headers = []);
75-
76-
/**
77-
* Generates a response with a 404 HTTP header and a given message.
78-
*
79-
* @param string $message
80-
* @param array $headers
81-
* @return mixed
82-
*/
83-
public function errorNotFound($message = '', array $headers = []);
84-
85-
/**
86-
* Generates a response with a 401 HTTP header and a given message.
87-
*
88-
* @param string $message
89-
* @param array $headers
90-
* @return mixed
91-
*/
92-
public function errorUnauthorized($message = '', array $headers = []);
93-
94-
/**
95-
* Generates a response with a 400 HTTP header and a given message.
96-
*
97-
* @param array $message
98-
* @param array $headers
99-
* @return mixed
100-
*/
101-
public function errorWrongArgs(array $message, array $headers = []);
102-
103-
/**
104-
* Generates a response with a 410 HTTP header and a given message.
105-
*
106-
* @param string $message
107-
* @param array $headers
108-
* @return mixed
109-
*/
110-
public function errorGone($message = '', array $headers = []);
111-
112-
/**
113-
* Generates a response with a 405 HTTP header and a given message.
114-
*
115-
* @param string $message
116-
* @param array $headers
117-
* @return mixed
118-
*/
119-
public function errorMethodNotAllowed($message = '', array $headers = []);
120-
121-
/**
122-
* Generates a Response with a 431 HTTP header and a given message.
123-
*
124-
* @param string $message
125-
* @param array $headers
126-
* @return mixed
127-
*/
128-
public function errorUnwillingToProcess($message = '', array $headers = []);
129-
130-
/**
131-
* Generates a Response with a 422 HTTP header and a given message.
132-
*
133-
* @param string $message
134-
* @param array $headers
135-
* @return mixed
136-
*/
137-
public function errorUnprocessable($message = '', array $headers = []);
13816
}

0 commit comments

Comments
 (0)