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

DannyvdSluijs / exact-online-meta-data-tool / 4612001500

pending completion
4612001500

push

github

GitHub
fix: Correct position check of deprecation message (#190)

1 of 3 new or added lines in 2 files covered. (33.33%)

217 of 272 relevant lines covered (79.78%)

18.27 hits per line

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

0.0
/MetaDataTool/Command/MetaDataBuilderCommand.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace MetaDataTool\Command;
6

7
use MetaDataTool\Config\EndpointCrawlerConfig;
8
use MetaDataTool\Crawlers\EndpointCrawler;
9
use MetaDataTool\Crawlers\MainPageCrawler;
10
use MetaDataTool\Enum\KnownEntities;
11
use MetaDataTool\JsonFileWriter;
12
use MetaDataTool\PageRegistry;
13
use Symfony\Component\Console\Command\Command;
14
use Symfony\Component\Console\Input\InputInterface;
15
use Symfony\Component\Console\Input\InputOption;
16
use Symfony\Component\Console\Output\OutputInterface;
17
use Symfony\Component\Console\Style\SymfonyStyle;
18

19
class MetaDataBuilderCommand extends Command
20
{
21
    private const MAINPAGE = 'https://start.exactonline.nl/docs/HlpRestAPIResources.aspx';
22
    protected static $defaultName = 'run';
23

24

25
    protected function configure(): void
26
    {
27
        $this
28
            ->setDescription('Scans the online ExactOnline documentation allowing to discover the API entities')
×
29
            ->setHelp(<<<'HELP'
×
30
                Scans the online ExactOnline documentation allowing to discover the API entities.....
31
HELP
32
            )->setDefinition([
×
33
                new InputOption(
×
34
                    'destination',
×
35
                    'd',
×
36
                    InputOption::VALUE_REQUIRED,
×
37
                    'The destination directory',
×
38
                    $this->defaultDestinationDirectory()
×
39
                ),
40
            ]);
41
    }
42

43
    protected function execute(InputInterface $input, OutputInterface $output): int
44
    {
45
        $destination = $input->getOption('destination');
×
46
        $io = new SymfonyStyle($input, $output);
×
47
        $io->title('Exact Online Meta Data Tool');
×
48

49

50
        if (! is_string($destination)) {
×
51
            $io->error('Invalid input for the destination option');
×
52
            die(1);
×
53
        }
54

55
        $io->info(['Scanning main page', self::MAINPAGE]);
×
56
        $mainPageCrawler = new MainPageCrawler(self::MAINPAGE);
×
57
        $pages = $mainPageCrawler->run();
×
NEW
58
        foreach (KnownEntities::keys() as $entity) {
×
NEW
59
            $pages->add('https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=' . $entity);
×
60
        }
61

62
        $io->info('Scanning entity pages');
×
63
        $io->progressStart($pages->count());
×
64

65
        $config = new EndpointCrawlerConfig(true);
×
66
        $endpoints = (new EndpointCrawler($config, $pages))
×
67
            ->run(static function() use ($io): void {
68
                $io->progressAdvance(1);
×
69
            });
×
70
        $io->progressFinish();
×
71

72
        $io->info('Creating meta data file');
×
73
        $writer = new JsonFileWriter($this->getFullDestinationPath($destination));
×
74
        $writer->write($endpoints);
×
75
        $io->success('Written meta data to ' . $writer->getFullFileName());
×
76

77
        return 0;
×
78
    }
79

80
    private function getFullDestinationPath(string $destination): string
81
    {
82
        if (strpos($destination, DIRECTORY_SEPARATOR) === 0 || strpos($destination, '.') === 0) {
×
83
            return $destination;
×
84
        }
85

86
        return $this->defaultDestinationDirectory() . DIRECTORY_SEPARATOR . $destination;
×
87
    }
88

89
    private function defaultDestinationDirectory(): string
90
    {
91
        $currentWorkingDirectory = getcwd();
×
92

93
        if ($currentWorkingDirectory === false) {
×
94
            throw new \RuntimeException('Unable to determine current working directory.');
×
95
        }
96

97
        return $currentWorkingDirectory;
×
98
    }
99
}
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