33namespace Psecio \Parse \Subscriber ;
44
55use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
6- use Symfony \Component \Console \Output \OutputInterface ;
7- use Psecio \Parse \Event \Events ;
86use Psecio \Parse \Event \FileEvent ;
97use Psecio \Parse \Event \IssueEvent ;
108use Psecio \Parse \Event \MessageEvent ;
119
1210/**
1311 * Display phpunit style dots to visualize scan progression
1412 */
15- class ConsoleDots implements EventSubscriberInterface, Events
13+ class ConsoleDots implements EventSubscriberInterface
1614{
17- /**
18- * @var OutputInterface Registered output
19- */
20- private $ output ;
15+ use Helper \SubscriberTrait, Helper \OutputTrait;
2116
2217 /**
2318 * @var string One charactes status descriptor
@@ -34,16 +29,6 @@ class ConsoleDots implements EventSubscriberInterface, Events
3429 */
3530 private $ fileCount ;
3631
37- /**
38- * Register output interface
39- *
40- * @param OutputInterface $output
41- */
42- public function __construct (OutputInterface $ output )
43- {
44- $ this ->output = $ output ;
45- }
46-
4732 /**
4833 * Set number of status chars per line
4934 *
@@ -55,24 +40,6 @@ public function setLineLength($lineLength)
5540 $ this ->lineLength = $ lineLength ;
5641 }
5742
58- /**
59- * Returns an array of event names this subscriber wants to listen to
60- *
61- * @return array The event names to listen to
62- */
63- public static function getSubscribedEvents ()
64- {
65- return [
66- self ::SCAN_START => 'onScanStart ' ,
67- self ::SCAN_COMPLETE => 'onScanComplete ' ,
68- self ::FILE_OPEN => 'onFileOpen ' ,
69- self ::FILE_CLOSE => 'onFileClose ' ,
70- self ::FILE_ISSUE => 'onFileIssue ' ,
71- self ::FILE_ERROR => 'onFileError ' ,
72- self ::DEBUG => 'onDebug '
73- ];
74- }
75-
7643 /**
7744 * Write header on scan start
7845 *
@@ -83,15 +50,6 @@ public function onScanStart()
8350 $ this ->fileCount = 0 ;
8451 }
8552
86- /**
87- * Ignore scan complete
88- *
89- * @return null
90- */
91- public function onScanComplete ()
92- {
93- }
94-
9553 /**
9654 * Set status to valid on file open
9755 *
@@ -138,26 +96,4 @@ public function onFileError(MessageEvent $event)
13896 {
13997 $ this ->status = '<error>E</error> ' ;
14098 }
141-
142- /**
143- * Ignore debug events
144- *
145- * @param MessageEvent $event
146- * @return null
147- */
148- public function onDebug (MessageEvent $ event )
149- {
150- }
151-
152- /**
153- * Write to console
154- *
155- * @param string $format sprintf format string
156- * @param mixed ...$arg Any number of sprintf arguments
157- * @return null
158- */
159- protected function write ()
160- {
161- $ this ->output ->write (call_user_func_array ('sprintf ' , func_get_args ()));
162- }
16399}
0 commit comments