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

AlexanderAllen / panettone / 8878745975

29 Apr 2024 12:42PM UTC coverage: 75.316% (-6.8%) from 82.143%
8878745975

push

github

web-flow
Add configuration file support. (#30)

* Rename main command to Main.

* Rename main command to Main.

* Rename entrypoint to app.

* Update Main command.

* Promote Setup trait for use in command.

* Turn api-platform links into permalinks.

* Initial test configuration file.

* Initial test boilerplate for configuration file.

* Cleanup local test output path on each test run.

* Test that configured namespace exists.

* Move config test to pan de agua.

* Add configuration file capability and update test.

* Add support for config param in command.

* Cleanup namespaces.

* Cleanup comment.

* Add use class for setup in media noche.

13 of 48 new or added lines in 4 files covered. (27.08%)

119 of 158 relevant lines covered (75.32%)

2.9 hits per line

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

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

3
declare(strict_types=1);
4

5
namespace AlexanderAllen\Panettone\Command;
6

7
use AlexanderAllen\Panettone\Bread\MediaNoche;
8
use AlexanderAllen\Panettone\Bread\PanDeAgua;
9
use AlexanderAllen\Panettone\Setup;
10
use Symfony\Component\Console\Attribute\AsCommand;
11
use Symfony\Component\Console\Command\Command;
12
use Symfony\Component\Console\Input\{InputInterface, InputArgument};
13
use Symfony\Component\Console\Output\OutputInterface;
14

15
#[AsCommand(
NEW
16
    name: 'panettone:bake',
×
NEW
17
    description: 'Generate PHP types.',
×
NEW
18
    hidden: false,
×
NEW
19
    aliases: ['panettone:generate']
×
NEW
20
)]
×
21
final class Main extends Command
22
{
23
    use Setup;
24

25
    protected function configure(): void
26
    {
NEW
27
        $this
×
NEW
28
            ->setHelp('Generates PHP types from a Open API source.')
×
NEW
29
            ->addArgument('source', InputArgument::REQUIRED, 'Open API YAML source');
×
30
    }
31

32
    protected function execute(InputInterface $input, OutputInterface $output): int
33
    {
34
        try {
NEW
35
            [$spec, $printer] = $this->realSetup($input->getArgument('source'), false);
×
NEW
36
            $config = $input->hasArgument('config') ? $input->getArgument('config') : null;
×
37

NEW
38
            $classes = [];
×
NEW
39
            foreach ($spec->components->schemas as $name => $schema) {
×
NEW
40
                $class = MediaNoche::newNetteClass($schema, $name);
×
NEW
41
                $classes[$name] = $class;
×
42
            }
43

NEW
44
            foreach ($classes as $name => $class_type) {
×
NEW
45
                PanDeAgua::printFile(
×
NEW
46
                    $printer,
×
NEW
47
                    $class_type,
×
NEW
48
                    PanDeAgua::getSettings($config)
×
NEW
49
                );
×
50
            }
NEW
51
        } catch (\Exception $th) {
×
NEW
52
            return Command::FAILURE;
×
53
        }
54

NEW
55
        return Command::SUCCESS;
×
56
    }
57
}
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