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

68publishers / tracy-git-version / 5982450498

26 Aug 2023 03:02AM UTC coverage: 90.041% (-2.2%) from 92.276%
5982450498

push

github

tg666
Coverage: using `pcov` instead of `phpdbg`

434 of 482 relevant lines covered (90.04%)

0.9 hits per line

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

89.29
/src/Bridge/Nette/DI/TracyGitVersionExportExtension.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace SixtyEightPublishers\TracyGitVersion\Bridge\Nette\DI;
6

7
use Nette\DI\CompilerExtension;
8
use Nette\DI\Definitions\Statement;
9
use Nette\Schema\Expect;
10
use Nette\Schema\Schema;
11
use RuntimeException;
12
use SixtyEightPublishers\TracyGitVersion\Repository\Command\GetHeadCommand;
13
use SixtyEightPublishers\TracyGitVersion\Repository\Command\GetLatestTagCommand;
14
use SixtyEightPublishers\TracyGitVersion\Repository\Export\CommandHandler\GetHeadCommandHandler;
15
use SixtyEightPublishers\TracyGitVersion\Repository\Export\CommandHandler\GetLatestTagCommandHandler;
16
use SixtyEightPublishers\TracyGitVersion\Repository\ExportedGitRepository;
17
use SixtyEightPublishers\TracyGitVersion\Repository\GitRepositoryInterface;
18
use function array_map;
19
use function assert;
20
use function count;
21
use function sprintf;
22

23
final class TracyGitVersionExportExtension extends CompilerExtension
24
{
25
    public function getConfigSchema(): Schema
26
    {
27
        $tempDir = $this->getContainerBuilder()->parameters['tempDir'] ?? null;
1✔
28

29
        return Expect::structure([
1✔
30
            'source_name' => Expect::string(GitRepositoryInterface::SOURCE_EXPORT),
1✔
31
            'export_filename' => Expect::string($tempDir ? $tempDir . '/git-version/repository.json' : null)->required(null === $tempDir),
1✔
32
            'command_handlers' => Expect::arrayOf(Expect::anyOf(Expect::type(Statement::class), Expect::string()), 'string')
1✔
33
                ->default([
1✔
34
                    GetHeadCommand::class => new Statement(GetHeadCommandHandler::class),
1✔
35
                    GetLatestTagCommand::class => new Statement(GetLatestTagCommandHandler::class),
1✔
36
                ])
37
                ->mergeDefaults()
1✔
38
                ->before(static function (array $items) {
1✔
39
                    return array_map(static function ($item) {
×
40
                        return $item instanceof Statement ? $item : new Statement($item);
×
41
                    }, $items);
×
42
                }),
1✔
43
        ])->castTo(TracyGitVersionExportConfig::class);
1✔
44
    }
45

46
    public function loadConfiguration(): void
47
    {
48
        if (0 >= count($this->compiler->getExtensions(TracyGitVersionExtension::class))) {
1✔
49
            throw new RuntimeException(sprintf(
1✔
50
                'The extension %s can be used only with %s.',
51
                self::class,
52
                TracyGitVersionExtension::class,
1✔
53
            ));
54
        }
55

56
        $builder = $this->getContainerBuilder();
1✔
57
        $config = $this->getConfig();
1✔
58
        assert($config instanceof TracyGitVersionExportConfig);
59

60
        # exported git repository
61
        $builder->addDefinition($this->prefix('git_repository.exported'))
1✔
62
            ->setAutowired(false)
1✔
63
            ->setFactory(ExportedGitRepository::class, [
1✔
64
                'file' => $config->export_filename,
1✔
65
                'handlers' => $config->command_handlers,
1✔
66
                'source' => $config->source_name,
1✔
67
            ])
68
            ->addTag(TracyGitVersionExtension::TAG_GIT_REPOSITORY, 50);
1✔
69
    }
1✔
70
}
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