PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.3.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.3.1
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
bit-form / vendor / typisttech / imposter / src / ConfigCollectionFactory.php

ConfigCollectionFactory.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 3.3.1, at vendor/typisttech/imposter/src/ConfigCollectionFactory.php

69 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace TypistTech\Imposter;
6
7 class ConfigCollectionFactory
8 {
9 public static function forProject(
10 ProjectConfigInterface $projectConfig,
11 Filesystem $filesystem
12 ): ConfigCollectionInterface {
13 return static::addRequiredPackageConfigsRecursively(
14 new ConfigCollection(),
15 $projectConfig,
16 $projectConfig,
17 $filesystem
18 );
19 }
20
21 private static function addRequiredPackageConfigsRecursively(
22 ConfigCollectionInterface $configCollection,
23 ProjectConfigInterface $projectConfig,
24 ConfigInterface $config,
25 Filesystem $filesystem
26 ): ConfigCollectionInterface {
27 $filteredRequires = static::getFilteredPackages($projectConfig, $config);
28
29 foreach ($filteredRequires as $package) {
30 $packageConfig = ConfigFactory::build(
31 $projectConfig->getVendorDir() . $package . '/composer.json',
32 $filesystem
33 );
34
35 $configCollection->add($packageConfig);
36
37 static::addRequiredPackageConfigsRecursively(
38 $configCollection,
39 $projectConfig,
40 $packageConfig,
41 $filesystem
42 );
43 }
44
45 return $configCollection;
46 }
47
48 /**
49 * @param ProjectConfigInterface $projectConfig
50 * @param ConfigInterface $config
51 *
52 * @return string[]
53 */
54 private static function getFilteredPackages(ProjectConfigInterface $projectConfig, ConfigInterface $config): array
55 {
56 $requiredPackages = array_filter($config->getRequires(), function (string $package) {
57 return (false !== strpos($package, '/'));
58 });
59
60 $nonComposerPackages = array_filter($requiredPackages, function (string $package) {
61 return (false === strpos($package, 'composer/'));
62 });
63
64 return array_filter($nonComposerPackages, function (string $package) use ($projectConfig) {
65 return ! in_array($package, $projectConfig->getExcludes(), true);
66 });
67 }
68 }
69