Segment.php
1.84 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
namespace ACP\Bookmark\Entity;
use AC\Type\ListScreenId;
use ACP\Bookmark\Type\SegmentId;
use InvalidArgumentException;
final class Segment {
/**
* @var SegmentId
*/
private $id;
/**
* @var ListScreenId
*/
private $list_screen_id;
/**
* @var int
*/
private $user_id;
/**
* @var string
*/
private $name;
/**
* @var array
*/
private $url_parameters;
/**
* @var bool
*/
private $global;
/**
* @param SegmentId $id
* @param ListScreenId $list_screen_id
* @param int $user_id
* @param string $name
* @param array $url_parameters
* @param bool $global
*/
public function __construct( SegmentId $id, ListScreenId $list_screen_id, $user_id, $name, array $url_parameters, $global ) {
$this->id = $id;
$this->list_screen_id = $list_screen_id;
$this->user_id = $user_id;
$this->name = $name;
$this->url_parameters = $url_parameters;
$this->global = $global;
$this->validate();
}
private function validate() {
if ( ! is_int( $this->user_id ) ) {
throw new InvalidArgumentException( 'Invalid user id.' );
}
if ( ! is_string( $this->name ) ) {
throw new InvalidArgumentException( 'Invalid name.' );
}
if ( ! is_bool( $this->global ) ) {
throw new InvalidArgumentException( 'Invalid global.' );
}
}
/**
* @return SegmentId
*/
public function get_id() {
return $this->id;
}
/**
* @return ListScreenId
*/
public function get_list_screen_id() {
return $this->list_screen_id;
}
/**
* @return int
*/
public function get_user_id() {
return $this->user_id;
}
/**
* @return string
*/
public function get_name() {
return $this->name;
}
/**
* @return array
*/
public function get_url_parameters() {
return $this->url_parameters;
}
/**
* @return bool
*/
public function is_global() {
return $this->global;
}
}