-
Notifications
You must be signed in to change notification settings - Fork 157
Expand file tree
/
Copy pathResourceInterface.php
More file actions
37 lines (31 loc) · 973 Bytes
/
ResourceInterface.php
File metadata and controls
37 lines (31 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
declare(strict_types=1);
namespace OpenStack\Common\Resource;
use Psr\Http\Message\ResponseInterface;
/**
* Represents an API resource.
*/
interface ResourceInterface
{
/**
* All models which represent an API resource should be able to be populated
* from a {@see ResponseInterface} object.
*
* @param \Psr\Http\Message\ResponseInterface $response
* @return self
*/
public function populateFromResponse(ResponseInterface $response);
/**
* @return self
*/
public function populateFromArray(array $data);
/**
* @template T of \OpenStack\Common\Resource\ResourceInterface
* @param class-string<T> $class the name of the model class
* @param mixed $data either a {@see ResponseInterface} or data array that will populate the newly
* created model class
*
* @return T
*/
public function model(string $class, $data = null): ResourceInterface;
}