• 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/UtilExtractTemplates.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\Exception\RuntimeException;
17
use Cecil\Util;
18
use Symfony\Component\Console\Input\InputArgument;
19
use Symfony\Component\Console\Input\InputDefinition;
20
use Symfony\Component\Console\Input\InputInterface;
21
use Symfony\Component\Console\Input\InputOption;
22
use Symfony\Component\Console\Output\OutputInterface;
23
use Symfony\Component\Finder\Finder;
24

25
/**
26
 * Extract built-in templates.
27
 */
28
class UtilExtractTemplates extends AbstractCommand
29
{
30
    /**
31
     * {@inheritdoc}
32
     */
33
    protected function configure()
34
    {
35
        $this
×
36
            ->setName('util:extract')
×
37
            ->setDescription('Extracts built-in templates')
×
38
            ->setDefinition(
×
39
                new InputDefinition([
×
40
                    new InputArgument('path', InputArgument::OPTIONAL, 'Use the given path as working directory'),
×
41
                    new InputOption('force', 'f', InputOption::VALUE_NONE, 'Override files if they already exist'),
×
42
                ])
×
43
            )
×
44
            ->setHelp('Extracts built-in templates in the "layouts" directory.');
×
45
    }
46

47
    /**
48
     * {@inheritdoc}
49
     *
50
     * @throws RuntimeException
51
     */
52
    protected function execute(InputInterface $input, OutputInterface $output)
53
    {
54
        $force = $input->getOption('force');
×
55

56
        try {
57
            $phar = new \Phar(Util\Plateform::getPharPath());
×
58

59
            $templatesList = [];
×
60
            $templates = Finder::create()
×
61
                ->files()
×
62
                ->in($this->getBuilder()->getConfig()->getInternalLayoutsPath());
×
63
            foreach ($templates as $template) {
×
64
                $templatesList[] = Util::joinPath((string) $this->getBuilder()->getConfig()->get('layouts.internal.dir'), Util\File::getFS()->makePathRelative($template->getPathname(), $this->getBuilder()->getConfig()->getInternalLayoutsPath()));
×
65
            }
66

67
            $phar->extractTo($this->getBuilder()->getConfig()->getLayoutsPath(), $templatesList, $force);
×
68
            Util\File::getFS()->mirror(Util::joinPath($this->getBuilder()->getConfig()->getLayoutsPath(), (string) $this->getBuilder()->getConfig()->get('layouts.internal.dir')), $this->getBuilder()->getConfig()->getLayoutsPath());
×
69
            Util\File::getFS()->remove(Util::joinPath($this->getBuilder()->getConfig()->getLayoutsPath(), 'resources'));
×
70
            $output->writeln(sprintf('<info>Built-in templates extracted to "%s".</info>', (string) $this->getBuilder()->getConfig()->get('layouts.dir')));
×
71
        } catch (\Exception $e) {
×
72
            throw new RuntimeException(sprintf($e->getMessage()));
×
73
        }
74

75
        return 0;
×
76
    }
77
}
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