1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author @jayS-de <[email protected]> |
4
|
|
|
* @created: 27.01.15, 18:22 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace Commercetools\Core\Model\State; |
8
|
|
|
|
9
|
|
|
use Commercetools\Core\Model\Common\Context; |
10
|
|
|
use Commercetools\Core\Model\Common\Reference; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @package Commercetools\Core\Model\State |
14
|
|
|
* @link https://dev.commercetools.com/http-api-types.html#reference-types |
15
|
|
|
* @link https://dev.commercetools.com/http-api-projects-states.html#state |
16
|
|
|
* @method string getTypeId() |
17
|
|
|
* @method StateReference setTypeId(string $typeId = null) |
18
|
|
|
* @method string getId() |
19
|
|
|
* @method StateReference setId(string $id = null) |
20
|
|
|
* @method State getObj() |
21
|
|
|
* @method StateReference setObj(State $obj = null) |
22
|
|
|
* @method string getKey() |
23
|
|
|
* @method StateReference setKey(string $key = null) |
24
|
|
|
*/ |
25
|
|
View Code Duplication |
class StateReference extends Reference |
|
|
|
|
26
|
|
|
{ |
27
|
|
|
const TYPE_STATE = 'state'; |
28
|
|
|
|
29
|
8 |
|
public function fieldDefinitions() |
30
|
|
|
{ |
31
|
8 |
|
$fields = parent::fieldDefinitions(); |
32
|
8 |
|
$fields[static::OBJ] = [static::TYPE => '\Commercetools\Core\Model\State\State']; |
33
|
|
|
|
34
|
8 |
|
return $fields; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param $id |
40
|
|
|
* @param Context|callable $context |
41
|
|
|
* @return StateReference |
42
|
|
|
*/ |
43
|
8 |
|
public static function ofId($id, $context = null) |
44
|
|
|
{ |
45
|
8 |
|
return static::ofTypeAndId(static::TYPE_STATE, $id, $context); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param $key |
50
|
|
|
* @param Context|callable $context |
51
|
|
|
* @return StateReference |
52
|
|
|
*/ |
53
|
|
|
public static function ofKey($key, $context = null) |
54
|
|
|
{ |
55
|
|
|
return static::ofTypeAndKey(static::TYPE_STATE, $key, $context); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.