Conditions | 4 |
Paths | 6 |
Total Lines | 57 |
Code Lines | 35 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
38 | protected function execute(InputInterface $input, OutputInterface $output) |
||
39 | { |
||
40 | $this->io = new SymfonyStyle($input, $output); |
||
41 | $this |
||
42 | ->io |
||
43 | ->title('Symfony PHP Assets Manager'); |
||
44 | $this |
||
45 | ->io |
||
46 | ->section('Watch assets changes'); |
||
47 | |||
48 | $configuration = $this->loadConfiguration($input); |
||
49 | |||
50 | // get debug mode |
||
51 | $this->debug = $configuration['debug']; |
||
52 | |||
53 | if ($this->debug) { |
||
54 | $this->io->note('Debug Mode...'); |
||
55 | } |
||
56 | |||
57 | // on Ctrl+C, we must stop to watch files |
||
58 | pcntl_signal(SIGTERM, [$this, 'stopWatch']); |
||
59 | pcntl_signal(SIGINT, [$this, 'stopWatch']); |
||
60 | |||
61 | $indexer = new FileIndexer(); |
||
62 | $sources = $this->collectSources($configuration['tasks']); |
||
63 | |||
64 | // start watching sources |
||
65 | $this |
||
66 | ->io |
||
67 | ->text('Watching...'); |
||
68 | |||
69 | while (!$this->shouldStop) { |
||
70 | $indexer->index($sources); |
||
71 | |||
72 | if ($indexer->hasChangedEntries()) { |
||
73 | $this |
||
74 | ->io |
||
75 | ->note('Sources has been modified...'); |
||
76 | |||
77 | $runCommand = new RunCommand(); |
||
78 | $runCommand->setContainer($this->container); |
||
79 | $runCommand->run(new ArrayInput([]), $output); |
||
80 | |||
81 | $this |
||
82 | ->io |
||
83 | ->text('Watching...'); |
||
84 | } |
||
85 | |||
86 | pcntl_signal_dispatch(); |
||
87 | sleep(1); |
||
88 | } |
||
89 | |||
90 | // display end message |
||
91 | $this->io->success('Assets watching end'); |
||
92 | |||
93 | return; |
||
94 | } |
||
95 | |||
134 |