1+ <?php
2+
3+ namespace App \Api \Builder {
4+
5+ use Agrirouter \Request \Payload \Endpoint \CapabilitySpecification \Capability ;
6+ use App \Definitions \CapabilityTypeDefinitions ;
7+
8+ /**
9+ * Builder for capabilities.
10+ * @package App\Api\Builder
11+ */
12+ class CapabilityBuilder
13+ {
14+ private array $ capabilities = [];
15+
16+ /**
17+ * Add capability.
18+ * @param int $direction Direction, could be sending or retrieving.
19+ * @return $this Instance of the builder for fluent style.
20+ */
21+ public function withTaskdata (int $ direction ): CapabilityBuilder
22+ {
23+ $ capability = new Capability ();
24+ $ capability ->setDirection ($ direction );
25+ $ capability ->setTechnicalMessageType (CapabilityTypeDefinitions::ISO_11783_TASKDATA_ZIP );
26+ array_push ($ this ->capabilities ,$ capability );
27+ return $ this ;
28+ }
29+
30+ /**
31+ * Add capability.
32+ * @param int $direction Direction, could be sending or retrieving.
33+ * @return $this Instance of the builder for fluent style.
34+ */
35+ public function withDeviceDescription (int $ direction ): CapabilityBuilder
36+ {
37+ $ capability = new Capability ();
38+ $ capability ->setDirection ($ direction );
39+ $ capability ->setTechnicalMessageType (CapabilityTypeDefinitions::ISO_11783_DEVICE_DESCRIPTION_PROTOBUF );
40+ array_push ($ this ->capabilities ,$ capability );
41+ return $ this ;
42+ }
43+
44+ /**
45+ * Add capability.
46+ * @param int $direction Direction, could be sending or retrieving.
47+ * @return $this Instance of the builder for fluent style.
48+ */
49+ public function withTimeLog (int $ direction ): CapabilityBuilder
50+ {
51+ $ capability = new Capability ();
52+ $ capability ->setDirection ($ direction );
53+ $ capability ->setTechnicalMessageType (CapabilityTypeDefinitions::ISO_11783_TIMELOG_PROTOBUF );
54+ array_push ($ this ->capabilities ,$ capability );
55+ return $ this ;
56+ }
57+
58+ /**
59+ * Add capability.
60+ * @param int $direction Direction, could be sending or retrieving.
61+ * @return $this Instance of the builder for fluent style.
62+ */
63+ public function withBmp (int $ direction ): CapabilityBuilder
64+ {
65+ $ capability = new Capability ();
66+ $ capability ->setDirection ($ direction );
67+ $ capability ->setTechnicalMessageType (CapabilityTypeDefinitions::IMG_BMP );
68+ array_push ($ this ->capabilities ,$ capability );
69+ return $ this ;
70+ }
71+
72+ /**
73+ * Add capability.
74+ * @param int $direction Direction, could be sending or retrieving.
75+ * @return $this Instance of the builder for fluent style.
76+ */
77+ public function withJpg (int $ direction ): CapabilityBuilder
78+ {
79+ $ capability = new Capability ();
80+ $ capability ->setDirection ($ direction );
81+ $ capability ->setTechnicalMessageType (CapabilityTypeDefinitions::IMG_JPEG );
82+ array_push ($ this ->capabilities ,$ capability );
83+ return $ this ;
84+ }
85+
86+ /**
87+ * Add capability.
88+ * @param int $direction Direction, could be sending or retrieving.
89+ * @return $this Instance of the builder for fluent style.
90+ */
91+ public function withPng (int $ direction ): CapabilityBuilder
92+ {
93+ $ capability = new Capability ();
94+ $ capability ->setDirection ($ direction );
95+ $ capability ->setTechnicalMessageType (CapabilityTypeDefinitions::IMG_PNG );
96+ array_push ($ this ->capabilities ,$ capability );
97+ return $ this ;
98+ }
99+
100+ /**
101+ * Add capability.
102+ * @param int $direction Direction, could be sending or retrieving.
103+ * @return $this Instance of the builder for fluent style.
104+ */
105+ public function withShape (int $ direction ): CapabilityBuilder
106+ {
107+ $ capability = new Capability ();
108+ $ capability ->setDirection ($ direction );
109+ $ capability ->setTechnicalMessageType (CapabilityTypeDefinitions::SHP_SHAPE_ZIP );
110+ array_push ($ this ->capabilities ,$ capability );
111+ return $ this ;
112+ }
113+
114+ /**
115+ * Add capability.
116+ * @param int $direction Direction, could be sending or retrieving.
117+ * @return $this Instance of the builder for fluent style.
118+ */
119+ public function withPdf (int $ direction ): CapabilityBuilder
120+ {
121+ $ capability = new Capability ();
122+ $ capability ->setDirection ($ direction );
123+ $ capability ->setTechnicalMessageType (CapabilityTypeDefinitions::DOC_PDF );
124+ array_push ($ this ->capabilities ,$ capability );
125+ return $ this ;
126+ }
127+
128+ /**
129+ * Add capability.
130+ * @param int $direction Direction, could be sending or retrieving.
131+ * @return $this Instance of the builder for fluent style.
132+ */
133+ public function withAvi (int $ direction ): CapabilityBuilder
134+ {
135+ $ capability = new Capability ();
136+ $ capability ->setDirection ($ direction );
137+ $ capability ->setTechnicalMessageType (CapabilityTypeDefinitions::VID_AVI );
138+ array_push ($ this ->capabilities ,$ capability );
139+ return $ this ;
140+ }
141+
142+ /**
143+ * Add capability.
144+ * @param int $direction Direction, could be sending or retrieving.
145+ * @return $this Instance of the builder for fluent style.
146+ */
147+ public function withMp4 (int $ direction ): CapabilityBuilder
148+ {
149+ $ capability = new Capability ();
150+ $ capability ->setDirection ($ direction );
151+ $ capability ->setTechnicalMessageType (CapabilityTypeDefinitions::VID_MP4 );
152+ array_push ($ this ->capabilities ,$ capability );
153+ return $ this ;
154+ }
155+
156+ /**
157+ * Add capability.
158+ * @param int $direction Direction, could be sending or retrieving.
159+ * @return $this Instance of the builder for fluent style.
160+ */
161+ public function withWmv (int $ direction ): CapabilityBuilder
162+ {
163+ $ capability = new Capability ();
164+ $ capability ->setDirection ($ direction );
165+ $ capability ->setTechnicalMessageType (CapabilityTypeDefinitions::VID_WMV );
166+ array_push ($ this ->capabilities ,$ capability );
167+ return $ this ;
168+ }
169+
170+ /**
171+ * Add capability.
172+ * @param int $direction Direction, could be sending or retrieving.
173+ * @return $this Instance of the builder for fluent style.
174+ */
175+ public function withGpsInfo (int $ direction ): CapabilityBuilder
176+ {
177+ $ capability = new Capability ();
178+ $ capability ->setDirection ($ direction );
179+ $ capability ->setTechnicalMessageType (CapabilityTypeDefinitions::GPS_INFO );
180+ array_push ($ this ->capabilities ,$ capability );
181+ return $ this ;
182+ }
183+
184+ /**
185+ * Build.
186+ * @return array Array containing all the capabilities defined.
187+ */
188+ public function build (): array
189+ {
190+ return $ this ->capabilities ;
191+ }
192+
193+ }
194+ }
0 commit comments