2222 */
2323
2424use IXP \Contracts \Grapher \Backend as GrapherBackendContract ;
25+ use IXP \Exceptions \Services \Grapher \CannotHandleRequestException ;
2526use IXP \Services \Grapher \Backend as GrapherBackend ;
2627
2728use IXP \Services \Grapher \Graph ;
3738use Log ;
3839
3940/**
40- * Grapher Backend -> Mrtg
41+ * Grapher Backend -> Sflow
4142 *
4243 * @author Barry O'Donovan <[email protected] > 4344 * @category Grapher
@@ -92,7 +93,7 @@ public function isMultiFileConfigurationSupported(): bool {
9293 *
9394 * {inheritDoc}
9495 *
95- * @param int $config_type The type of configuration to generate
96+ * @param int $type The type of configuration to generate
9697 * @return array
9798 */
9899 public function generateConfiguration ( int $ type = self ::GENERATED_CONFIG_TYPE_MONOLITHIC ): array
@@ -140,7 +141,10 @@ public static function supports(): array {
140141 * {inheritDoc}
141142 *
142143 * @param \IXP\Services\Grapher\Graph $graph
144+ *
143145 * @return array
146+ *
147+ * @throws
144148 */
145149 public function data ( Graph $ graph ): array {
146150 try {
@@ -158,7 +162,10 @@ public function data( Graph $graph ): array {
158162 * {inheritDoc}
159163 *
160164 * @param Graph $graph
165+ *
161166 * @return string
167+ *
168+ * @throws
162169 */
163170 public function png ( Graph $ graph ): string {
164171 try {
@@ -176,7 +183,10 @@ public function png( Graph $graph ): string {
176183 * {inheritDoc}
177184 *
178185 * @param Graph $graph
186+ *
179187 * @return string
188+ *
189+ * @throws
180190 */
181191 public function rrd ( Graph $ graph ): string {
182192 try {
@@ -206,26 +216,31 @@ private function translateCategory( $c ): string {
206216 * For a given graph, return the filename where the appropriate data
207217 * will be found.
208218 *
209- * @param Graph $graph
219+ * @param Graph $graph
220+ * @param string $type
221+ *
210222 * @return string
223+ *
224+ * @throws
211225 */
212226 private function resolveFileName ( Graph $ graph , $ type ): string {
213- $ config = config ('grapher.backends.sflow ' );
214-
215227 switch ( $ graph ->classType () ) {
216228 case 'Vlan ' :
229+ /** @var Graph\Vlan $graph */
217230 return sprintf ( "aggregate.%s.%s.vlan%05d.%s " ,
218231 $ graph ->protocol (), $ this ->translateCategory ( $ graph ->category () ),
219232 $ graph ->vlan ()->getNumber (), $ type );
220233 break ;
221234
222235 case 'VlanInterface ' :
236+ /** @var Graph\VlanInterface $graph */
223237 return sprintf ( "individual.%s.%s.src-%05d.%s " ,
224238 $ graph ->protocol (), $ this ->translateCategory ( $ graph ->category () ),
225239 $ graph ->vlanInterface ()->getId (), $ type );
226240 break ;
227241
228242 case 'P2p ' :
243+ /** @var Graph\P2p $graph */
229244 return sprintf ( "p2p.%s.%s.src-%05d.dst-%05d.%s " ,
230245 $ graph ->protocol (), $ this ->translateCategory ( $ graph ->category () ),
231246 $ graph ->svli ()->getId (), $ graph ->dvli ()->getId (), $ type );
@@ -241,25 +256,31 @@ private function resolveFileName( Graph $graph, $type ): string {
241256 * will be found.
242257 *
243258 * @param Graph $graph
259+ *
244260 * @return string
261+ *
262+ * @throws
245263 */
246264 private function resolveFilePath ( Graph $ graph , $ type ): string {
247265 $ config = config ('grapher.backends.sflow ' );
248266
249267 switch ( $ graph ->classType () ) {
250268 case 'Vlan ' :
269+ /** @var Graph\Vlan $graph */
251270 return sprintf ( "%s/%s/%s/aggregate/%s " , $ config ['root ' ],
252271 $ graph ->protocol (), $ this ->translateCategory ( $ graph ->category () ),
253272 $ this ->resolveFileName ( $ graph , $ type ) );
254273 break ;
255274
256275 case 'VlanInterface ' :
276+ /** @var Graph\VlanInterface $graph */
257277 return sprintf ( "%s/%s/%s/individual/%s " , $ config ['root ' ],
258278 $ graph ->protocol (), $ this ->translateCategory ( $ graph ->category () ),
259279 $ this ->resolveFileName ( $ graph , $ type ) );
260280 break ;
261281
262282 case 'P2p ' :
283+ /** @var Graph\P2p $graph */
263284 return sprintf ( "%s/%s/%s/p2p/src-%05d/%s " , $ config ['root ' ],
264285 $ graph ->protocol (), $ this ->translateCategory ( $ graph ->category () ),
265286 $ graph ->svli ()->getId (), $ this ->resolveFileName ( $ graph , $ type ) );
0 commit comments