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

Cecilapp / Cecil / 21146412611

19 Jan 2026 05:26PM UTC coverage: 82.274%. First build
21146412611

Pull #2285

github

web-flow
Merge fe78c7058 into 878eab640
Pull Request #2285: Integrate PHP-DI for dependency injection

58 of 83 new or added lines in 16 files covered. (69.88%)

3328 of 4045 relevant lines covered (82.27%)

0.82 hits per line

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

63.64
/src/Step/Pages/Generate.php
1
<?php
2

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

12
declare(strict_types=1);
13

14
namespace Cecil\Step\Pages;
15

16
use Cecil\Builder;
17
use Cecil\Config;
18
use Cecil\Generator\GeneratorManager;
19
use Cecil\Step\AbstractStep;
20
use DI\Attribute\Inject;
21
use Psr\Log\LoggerInterface;
22

23
/**
24
 * Generate pages step.
25
 *
26
 * This step is responsible for generating pages based on the configured generators.
27
 * It initializes the generator manager with the generators defined in the configuration
28
 * and processes them to create the pages. The generated pages are then set in the builder.
29
 */
30
class Generate extends AbstractStep
31
{
32
    #[Inject]
33
    private GeneratorManager $generatorManager;
34

35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function getName(): string
39
    {
40
        return 'Generating pages';
1✔
41
    }
42

43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function init(array $options): void
47
    {
48
        if (\count((array) $this->config->get('pages.generators')) > 0) {
1✔
49
            $this->canProcess = true;
1✔
50
        }
51
    }
52

53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function process(): void
57
    {
58
        $generators = (array) $this->config->get('pages.generators');
1✔
59
        array_walk($generators, function ($generator, $priority) {
1✔
60
            if (!class_exists($generator)) {
1✔
61
                $message = \sprintf('Unable to load generator "%s" (priority: %s).', $generator, $priority);
1✔
62
                $this->logger->error($message);
1✔
63

64
                return;
1✔
65
            }
66
            // Use DI container to create the generator; fail loudly if it cannot be resolved
67
            try {
68
                $generatorInstance = $this->builder->get($generator);
1✔
NEW
69
            } catch (\Throwable $e) {
×
NEW
70
                $this->logger->error(\sprintf(
×
NEW
71
                    'Unable to instantiate generator "%s" (priority: %s): %s',
×
NEW
72
                    $generator,
×
NEW
73
                    $priority,
×
NEW
74
                    $e->getMessage()
×
NEW
75
                ));
×
76

NEW
77
                throw $e;
×
78
            }
79
            $this->generatorManager->addGenerator($generatorInstance, $priority);
1✔
80
        });
1✔
81
        $pages = $this->generatorManager->process();
1✔
82
        $this->builder->setPages($pages);
1✔
83
    }
84
}
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