• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Cecilapp / Cecil / 5046064611

pending completion
5046064611

push

github

GitHub
perf: native_function_invocation (#1697)

322 of 322 new or added lines in 62 files covered. (100.0%)

2784 of 4121 relevant lines covered (67.56%)

0.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Command/Clear.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of Cecil.
7
 *
8
 * Copyright (c) Arnaud Ligny <arnaud@ligny.fr>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13

14
namespace Cecil\Command;
15

16
use Cecil\Util;
17
use Symfony\Component\Console\Input\InputArgument;
18
use Symfony\Component\Console\Input\InputDefinition;
19
use Symfony\Component\Console\Input\InputInterface;
20
use Symfony\Component\Console\Output\OutputInterface;
21

22
/**
23
 * Removes generated and temporary files.
24
 */
25
class Clear extends AbstractCommand
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30
    protected function configure()
31
    {
32
        $this
×
33
            ->setName('clear')
×
34
            ->setDescription('Removes generated files')
×
35
            ->setDefinition(
×
36
                new InputDefinition([
×
37
                    new InputArgument('path', InputArgument::OPTIONAL, 'Use the given path as working directory'),
×
38
                ])
×
39
            )
×
40
            ->setHelp('Removes generated, temporary and cache files');
×
41
    }
42

43
    /**
44
     * {@inheritdoc}
45
     */
46
    protected function execute(InputInterface $input, OutputInterface $output)
47
    {
48
        $this->removeOutputDir($output);
×
49
        $this->removeTmpDir($output);
×
50

51
        // deletes cache
52
        $command = $this->getApplication()->find('cache:clear');
×
53
        $command->run($input, $output);
×
54

55
        return 0;
×
56
    }
57

58
    /**
59
     * Deletes output directory.
60
     */
61
    private function removeOutputDir(OutputInterface $output): void
62
    {
63
        $outputDir = (string) $this->getBuilder()->getConfig()->get('output.dir');
×
64
        if (Util\File::getFS()->exists(Util::joinFile($this->getPath(), self::TMP_DIR, 'output'))) {
×
65
            $outputDir = Util\File::fileGetContents(Util::joinFile($this->getPath(), self::TMP_DIR, 'output'));
×
66
        }
67

68
        if ($outputDir === false || !Util\File::getFS()->exists(Util::joinFile($this->getPath(), $outputDir))) {
×
69
            $output->writeln('<info>No output directory.</info>');
×
70

71
            return;
×
72
        }
73

74
        $output->writeln('Removing output directory...');
×
75
        $output->writeln(
×
76
            sprintf('<comment>Path: %s</comment>', Util::joinFile($this->getPath(), $outputDir)),
×
77
            OutputInterface::VERBOSITY_VERBOSE
×
78
        );
×
79
        Util\File::getFS()->remove(Util::joinFile($this->getPath(), $outputDir));
×
80
        $output->writeln('<info>Output directory is clear.</info>');
×
81
    }
82

83
    /**
84
     * Deletes local server temporary files.
85
     */
86
    private function removeTmpDir(OutputInterface $output): void
87
    {
88
        if (!Util\File::getFS()->exists(Util::joinFile($this->getPath(), self::TMP_DIR))) {
×
89
            $output->writeln('<info>No temporary files.</info>');
×
90

91
            return;
×
92
        }
93

94
        $output->writeln('Removing temporary directory...');
×
95
        $output->writeln(
×
96
            sprintf('<comment>Path: %s</comment>', Util::joinFile($this->getPath(), self::TMP_DIR)),
×
97
            OutputInterface::VERBOSITY_VERBOSE
×
98
        );
×
99
        Util\File::getFS()->remove(Util::joinFile($this->getPath(), self::TMP_DIR));
×
100
        $output->writeln('<info>Temporary directory is clear.</info>');
×
101
    }
102
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc