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 / Config.php

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

82 lines 1.7 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 Config implements ConfigInterface
8 {
9 /**
10 * @var string
11 */
12 protected $packageDir;
13
14 /**
15 * @var array
16 */
17 private $config;
18
19 public function __construct(string $packageDir, array $config)
20 {
21 $this->packageDir = StringUtil::addTrailingSlash($packageDir);
22 $this->config = $config;
23 }
24
25 /**
26 * @return string[]
27 */
28 public function getAutoloads(): array
29 {
30 return array_map(function (string $autoload): string {
31 return $this->packageDir . $autoload;
32 }, array_unique($this->getAutoloadPaths()));
33 }
34
35 /**
36 * @return string[]
37 */
38 private function getAutoloadPaths(): array
39 {
40 $autoloads = $this->get('autoload');
41 unset($autoloads['exclude-from-classmap']);
42
43 return ArrayUtil::flattenMap(function ($autoloadConfig): array {
44 return $this->normalizeAutoload($autoloadConfig);
45 }, $autoloads);
46 }
47
48 protected function get(string $key): array
49 {
50 return $this->config[$key] ?? [];
51 }
52
53 /**
54 * @param $autoloadConfigs
55 *
56 * @return string[]
57 */
58 private function normalizeAutoload($autoloadConfigs): array
59 {
60 if (! is_array($autoloadConfigs)) {
61 return [$autoloadConfigs];
62 }
63
64 return ArrayUtil::flattenMap(function ($autoloadConfig): array {
65 return $this->normalizeAutoload($autoloadConfig);
66 }, $autoloadConfigs);
67 }
68
69 public function getPackageDir(): string
70 {
71 return $this->packageDir;
72 }
73
74 /**
75 * @return string[]
76 */
77 public function getRequires(): array
78 {
79 return array_keys($this->get('require'));
80 }
81 }
82