console-helpers /
svn-buddy
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * This file is part of the SVN-Buddy library. |
||
| 4 | * For the full copyright and license information, please view |
||
| 5 | * the LICENSE file that was distributed with this source code. |
||
| 6 | * |
||
| 7 | * @copyright Alexander Obuhovich <[email protected]> |
||
| 8 | * @link https://github.com/console-helpers/svn-buddy |
||
| 9 | */ |
||
| 10 | |||
| 11 | namespace ConsoleHelpers\SVNBuddy; |
||
| 12 | |||
| 13 | |||
| 14 | use ConsoleHelpers\SVNBuddy\Cache\CacheManager; |
||
| 15 | use ConsoleHelpers\DatabaseMigration\MigrationManager; |
||
| 16 | use ConsoleHelpers\DatabaseMigration\PhpMigrationRunner; |
||
| 17 | use ConsoleHelpers\DatabaseMigration\SqlMigrationRunner; |
||
| 18 | use ConsoleHelpers\SVNBuddy\Config\CommandConfig; |
||
| 19 | use ConsoleHelpers\SVNBuddy\Database\StatementProfiler; |
||
| 20 | use ConsoleHelpers\SVNBuddy\Helper\DateHelper; |
||
| 21 | use ConsoleHelpers\SVNBuddy\Helper\OutputHelper; |
||
| 22 | use ConsoleHelpers\SVNBuddy\Helper\SizeHelper; |
||
| 23 | use ConsoleHelpers\SVNBuddy\MergeSourceDetector\ClassicMergeSourceDetector; |
||
| 24 | use ConsoleHelpers\SVNBuddy\MergeSourceDetector\InPortalMergeSourceDetector; |
||
| 25 | use ConsoleHelpers\SVNBuddy\MergeSourceDetector\MergeSourceDetectorAggregator; |
||
| 26 | use ConsoleHelpers\SVNBuddy\Process\ProcessFactory; |
||
| 27 | use ConsoleHelpers\SVNBuddy\Repository\CommitMessageBuilder; |
||
| 28 | use ConsoleHelpers\SVNBuddy\Repository\Connector\Connector; |
||
| 29 | use ConsoleHelpers\SVNBuddy\Repository\Connector\UrlResolver; |
||
| 30 | use ConsoleHelpers\SVNBuddy\Repository\Parser\LogMessageParserFactory; |
||
| 31 | use ConsoleHelpers\SVNBuddy\Repository\Parser\RevisionListParser; |
||
| 32 | use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\DatabaseManager; |
||
| 33 | use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\RevisionLogFactory; |
||
| 34 | use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\RevisionPrinter; |
||
| 35 | use ConsoleHelpers\SVNBuddy\Repository\WorkingCopyResolver; |
||
| 36 | use Symfony\Component\Console\Formatter\OutputFormatterStyle; |
||
| 37 | use Symfony\Component\Console\Output\OutputInterface; |
||
| 38 | |||
| 39 | class Container extends \ConsoleHelpers\ConsoleKit\Container |
||
| 40 | { |
||
| 41 | |||
| 42 | /** |
||
| 43 | * {@inheritdoc} |
||
| 44 | */ |
||
| 45 | 176 | public function __construct(array $values = array()) |
|
| 46 | { |
||
| 47 | 176 | parent::__construct($values); |
|
| 48 | |||
| 49 | 176 | $this['app_name'] = 'SVN-Buddy'; |
|
| 50 | 176 | $this['app_version'] = '@git-version@'; |
|
| 51 | |||
| 52 | 176 | $this['working_directory_sub_folder'] = '.svn-buddy'; |
|
| 53 | |||
| 54 | 176 | $this['config_defaults'] = array( |
|
| 55 | 176 | 'repository-connector.username' => '', |
|
| 56 | 176 | 'repository-connector.password' => '', |
|
| 57 | 176 | 'repository-connector.last-revision-cache-duration' => '10 minutes', |
|
| 58 | 176 | 'update-channel' => 'stable', |
|
| 59 | ); |
||
| 60 | |||
| 61 | $this->extend('output', function ($output) { |
||
| 62 | /** @var OutputInterface $output */ |
||
| 63 | 176 | $output->getFormatter()->setStyle('debug', new OutputFormatterStyle('white', 'magenta')); |
|
| 64 | |||
| 65 | 9 | return $output; |
|
| 66 | 176 | }); |
|
| 67 | |||
| 68 | $this['process_factory'] = function () { |
||
| 69 | 7 | return new ProcessFactory(); |
|
| 70 | }; |
||
| 71 | |||
| 72 | $this['merge_source_detector'] = function () { |
||
| 73 | 1 | $merge_source_detector = new MergeSourceDetectorAggregator(0); |
|
| 74 | 1 | $merge_source_detector->add(new ClassicMergeSourceDetector(0)); |
|
| 75 | 1 | $merge_source_detector->add(new InPortalMergeSourceDetector(50)); |
|
| 76 | |||
| 77 | 1 | return $merge_source_detector; |
|
| 78 | }; |
||
| 79 | |||
| 80 | $this['repository_url_resolver'] = function ($c) { |
||
|
0 ignored issues
–
show
|
|||
| 81 | 1 | return new UrlResolver($c['repository_connector']); |
|
| 82 | }; |
||
| 83 | |||
| 84 | $this['cache_manager'] = function ($c) { |
||
| 85 | 7 | return new CacheManager($c['working_directory'], $c['size_helper'], $c['io']); |
|
| 86 | }; |
||
| 87 | |||
| 88 | $this['statement_profiler'] = function () { |
||
| 89 | 20 | $statement_profiler = new StatementProfiler(); |
|
| 90 | |||
| 91 | // The "AbstractPlugin::getLastRevision" method. |
||
| 92 | 20 | $statement_profiler->ignoreDuplicateStatement('SELECT LastRevision FROM PluginData WHERE Name = :name'); |
|
| 93 | |||
| 94 | // The "AbstractPlugin::getProject" method. |
||
| 95 | 20 | $statement_profiler->ignoreDuplicateStatement('SELECT Id FROM Projects WHERE Path = :path'); |
|
| 96 | |||
| 97 | // The "AbstractDatabaseCollectorPlugin::getProjects" method. |
||
| 98 | 20 | $statement_profiler->ignoreDuplicateStatement( |
|
| 99 | 'SELECT Path, Id AS PathId, RevisionAdded, RevisionDeleted, RevisionLastSeen |
||
| 100 | FROM Paths |
||
| 101 | WHERE PathHash IN (:path_hashes)' |
||
| 102 | 20 | ); |
|
| 103 | |||
| 104 | // The "ProjectsPlugin::createRepositoryWideProject" method. |
||
| 105 | 20 | $statement_profiler->ignoreDuplicateStatement( |
|
| 106 | 'SELECT Id FROM Paths WHERE ProjectPath = :project_path LIMIT 100' |
||
| 107 | 20 | ); |
|
| 108 | |||
| 109 | 20 | $statement_profiler->setActive(true); |
|
| 110 | 20 | $statement_profiler->trackDuplicates(false); |
|
| 111 | |||
| 112 | 20 | return $statement_profiler; |
|
| 113 | }; |
||
| 114 | |||
| 115 | $this['project_root_folder'] = function () { |
||
| 116 | 150 | return dirname(dirname(__DIR__)); |
|
| 117 | }; |
||
| 118 | |||
| 119 | $this['migration_manager'] = function ($c) { |
||
| 120 | 150 | $migrations_directory = $c['project_root_folder'] . '/migrations'; |
|
| 121 | 150 | $migration_manager = new MigrationManager($migrations_directory, $c); |
|
| 122 | 150 | $migration_manager->registerMigrationRunner(new SqlMigrationRunner()); |
|
| 123 | 150 | $migration_manager->registerMigrationRunner(new PhpMigrationRunner()); |
|
| 124 | |||
| 125 | 150 | return $migration_manager; |
|
| 126 | }; |
||
| 127 | |||
| 128 | $this['db_manager'] = function ($c) { |
||
| 129 | 2 | return new DatabaseManager($c['working_directory'], $c['migration_manager'], $c['statement_profiler']); |
|
| 130 | }; |
||
| 131 | |||
| 132 | $this['revision_log_factory'] = function ($c) { |
||
| 133 | 2 | return new RevisionLogFactory( |
|
| 134 | 2 | $c['repository_connector'], |
|
| 135 | 2 | $c['db_manager'], |
|
| 136 | 2 | $c['log_message_parser_factory'] |
|
| 137 | 2 | ); |
|
| 138 | }; |
||
| 139 | |||
| 140 | $this['log_message_parser_factory'] = function () { |
||
| 141 | 3 | return new LogMessageParserFactory(); |
|
| 142 | }; |
||
| 143 | |||
| 144 | $this['revision_list_parser'] = function () { |
||
| 145 | 2 | return new RevisionListParser(); |
|
| 146 | }; |
||
| 147 | |||
| 148 | $this['revision_printer'] = function ($c) { |
||
| 149 | 1 | return new RevisionPrinter($c['date_helper'], $c['output_helper']); |
|
| 150 | }; |
||
| 151 | |||
| 152 | $this['repository_connector'] = function ($c) { |
||
| 153 | 6 | return new Connector($c['config_editor'], $c['process_factory'], $c['io'], $c['cache_manager']); |
|
| 154 | }; |
||
| 155 | |||
| 156 | $this['commit_message_builder'] = function ($c) { |
||
| 157 | 1 | return new CommitMessageBuilder( |
|
| 158 | 1 | $c['repository_connector'], |
|
| 159 | 1 | $c['revision_list_parser'], |
|
| 160 | 1 | $c['revision_log_factory'] |
|
| 161 | 1 | ); |
|
| 162 | }; |
||
| 163 | |||
| 164 | $this['working_copy_resolver'] = function ($c) { |
||
| 165 | 2 | return new WorkingCopyResolver($c['repository_connector']); |
|
| 166 | }; |
||
| 167 | |||
| 168 | $this['command_config'] = function ($c) { |
||
| 169 | 1 | return new CommandConfig($c['config_editor'], $c['working_copy_resolver']); |
|
| 170 | }; |
||
| 171 | |||
| 172 | $this['date_helper'] = function () { |
||
| 173 | 2 | return new DateHelper(); |
|
| 174 | }; |
||
| 175 | |||
| 176 | $this['size_helper'] = function () { |
||
| 177 | 8 | return new SizeHelper(); |
|
| 178 | }; |
||
| 179 | |||
| 180 | $this['output_helper'] = function () { |
||
| 181 | 2 | return new OutputHelper(); |
|
| 182 | }; |
||
| 183 | |||
| 184 | 1 | $this['editor'] = function () { |
|
| 185 | 1 | return new InteractiveEditor(); |
|
| 186 | }; |
||
| 187 | 176 | } |
|
| 188 | |||
| 189 | } |
||
| 190 |
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.