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

valksor / php-dev-snapshot / 19634210989

24 Nov 2025 12:21PM UTC coverage: 61.538%. First build
19634210989

push

github

k0d3r1s
add valksor-dev snapshot

336 of 546 new or added lines in 4 files covered. (61.54%)

336 of 546 relevant lines covered (61.54%)

2.88 hits per line

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

21.95
/DependencyInjection/SnapshotConfiguration.php
1
<?php declare(strict_types = 1);
2

3
/*
4
 * This file is part of the Valksor package.
5
 *
6
 * (c) Davis Zalitis (k0d3r1s)
7
 * (c) SIA Valksor <packages@valksor.com>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12

13
namespace ValksorDev\Snapshot\DependencyInjection;
14

15
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
18
use Valksor\Bundle\DependencyInjection\AbstractDependencyConfiguration;
19
use Valksor\Bundle\ValksorBundle;
20

21
use function sprintf;
22

23
/**
24
 * Snapshot command dependency injection configuration.
25
 *
26
 * This class defines the configuration schema for the Snapshot command,
27
 * enabling proper dependency injection and service registration within
28
 * the Valksor framework.
29
 *
30
 * Configuration Structure:
31
 * - enabled: Master switch to enable/disable snapshot functionality
32
 * - options: Default options for snapshot generation
33
 *
34
 * Integration:
35
 * This configuration integrates with the ValksorBundle's dependency injection
36
 * system to automatically register Snapshot services when enabled.
37
 */
38
class SnapshotConfiguration extends AbstractDependencyConfiguration
39
{
40
    public function addSection(
41
        ArrayNodeDefinition $rootNode,
42
        callable $enableIfStandalone,
43
        string $component,
44
    ): void {
NEW
45
        $rootNode
×
NEW
46
            ->children()
×
NEW
47
                ->arrayNode($component)
×
NEW
48
                    ->{$enableIfStandalone(sprintf('%s/%s', ValksorBundle::VALKSOR, $component), self::class)}()
×
NEW
49
                    ->addDefaultsIfNotSet()
×
NEW
50
                    ->children()
×
NEW
51
                        ->booleanNode('enabled')
×
NEW
52
                            ->info('Enable or disable the snapshot command')
×
NEW
53
                            ->example('true')
×
NEW
54
                            ->defaultFalse()
×
NEW
55
                        ->end()
×
NEW
56
                        ->arrayNode('options')
×
NEW
57
                            ->info('Default options for snapshot generation')
×
NEW
58
                            ->addDefaultsIfNotSet()
×
NEW
59
                            ->children()
×
NEW
60
                                ->integerNode('max_files')
×
NEW
61
                                    ->info('Maximum number of files to process (0 for unlimited)')
×
NEW
62
                                    ->example('500')
×
NEW
63
                                    ->defaultValue(500)
×
NEW
64
                                    ->min(0)
×
NEW
65
                                ->end()
×
NEW
66
                                ->integerNode('max_file_size')
×
NEW
67
                                    ->info('Maximum file size in bytes (0 for unlimited)')
×
NEW
68
                                    ->example('1048576')
×
NEW
69
                                    ->defaultValue(1048576) // 1MB
×
NEW
70
                                    ->min(0)
×
NEW
71
                                ->end()
×
NEW
72
                                ->integerNode('max_lines')
×
NEW
73
                                    ->info('Maximum lines per file (0 for unlimited)')
×
NEW
74
                                    ->example('1000')
×
NEW
75
                                    ->defaultValue(1000)
×
NEW
76
                                    ->min(0)
×
NEW
77
                                ->end()
×
NEW
78
                                ->booleanNode('include_vendors')
×
NEW
79
                                    ->info('Include vendor directories by default')
×
NEW
80
                                    ->example('false')
×
NEW
81
                                    ->defaultFalse()
×
NEW
82
                                ->end()
×
NEW
83
                                ->booleanNode('include_hidden')
×
NEW
84
                                    ->info('Include hidden files and directories by default')
×
NEW
85
                                    ->example('false')
×
NEW
86
                                    ->defaultFalse()
×
NEW
87
                                ->end()
×
NEW
88
                                ->booleanNode('use_gitignore')
×
NEW
89
                                    ->info('Use .gitignore patterns by default')
×
NEW
90
                                    ->example('true')
×
NEW
91
                                    ->defaultTrue()
×
NEW
92
                                ->end()
×
NEW
93
                                ->arrayNode('exclude')
×
NEW
94
                                    ->info('Default exclusion patterns for snapshot generation')
×
NEW
95
                                    ->example([
×
NEW
96
                                        'tests', 'Tests', 'coverage', '.coverage', 'build', 'dist',
×
NEW
97
                                        'node_modules', 'vendor', '.git', '.idea', '.phpunit.cache',
×
NEW
98
                                        '**/*.log', '**/.DS_Store',
×
NEW
99
                                    ])
×
NEW
100
                                    ->defaultValue(self::getDefaults()['options']['exclude'])
×
NEW
101
                                    ->scalarPrototype()->end()
×
NEW
102
                                ->end()
×
NEW
103
                            ->end()
×
NEW
104
                        ->end()
×
NEW
105
                    ->end()
×
NEW
106
                ->end()
×
NEW
107
            ->end();
×
108
    }
109

110
    public function registerPreConfiguration(
111
        ContainerConfigurator $container,
112
        ContainerBuilder $builder,
113
        string $component,
114
    ): void {
115
        // No pre-configuration needed for Snapshot
NEW
116
    }
×
117

118
    public static function getDefaults(): array
119
    {
120
        return [
5✔
121
            'options' => [
5✔
122
                'max_files' => 500,
5✔
123
                'max_file_size' => 1048576, // 1MB
5✔
124
                'max_lines' => 1000,
5✔
125
                'include_vendors' => false,
5✔
126
                'include_hidden' => false,
5✔
127
                'use_gitignore' => false,
5✔
128
                'exclude' => [
5✔
129
                    // Test and build directories (anywhere in project)
130
                    'tests', 'Tests', 'coverage', '.coverage', 'build', 'dist', 'out',
5✔
131

132
                    // Cache and temporary directories (anywhere in project)
133
                    '.phpunit.cache', 'cache', 'tmp', 'temp',
5✔
134

135
                    // Large dependency directories (anywhere in project)
136
                    'node_modules', 'vendor',
5✔
137

138
                    // Development and IDE directories (anywhere in project)
139
                    '.git', '.idea', '.vscode', '.webpack-cache', '.cache', '.env', '.env.local',
5✔
140

141
                    // Lock files and build artifacts
142
                    '.neon', '.lock', 'LICENSE', '.md', 'reference.php', '.mcp',
5✔
143

144
                    // File patterns by extension/type
145
                    '**/*.log', '**/.DS_Store', '**/*.lock',
5✔
146
                ],
5✔
147
            ],
5✔
148
        ];
5✔
149
    }
150
}
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