Passed
Push — master ( 834d7a...3b951f )
by Jonathan
06:19
created
app/Services/ComposerService.php 2 patches
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -27,86 +27,86 @@
 block discarded – undo
27 27
 class ComposerService
28 28
 {
29 29
 
30
-    /**
31
-     * Checks whether a Composer package is a MyArtJaub one.
32
-     *
33
-     * @param PackageInterface $package
34
-     * @return bool
35
-     */
36
-    public function isMyArtJaubPackage(PackageInterface $package): bool
37
-    {
38
-        list($vendor) = explode('/', $package->getName(), 2);
39
-        return $vendor == self::MYARTJAUB_VENDOR;
40
-    }
30
+                                /**
31
+                                 * Checks whether a Composer package is a MyArtJaub one.
32
+                                 *
33
+                                 * @param PackageInterface $package
34
+                                 * @return bool
35
+                                 */
36
+                                public function isMyArtJaubPackage(PackageInterface $package): bool
37
+                                {
38
+                                list($vendor) = explode('/', $package->getName(), 2);
39
+                                return $vendor == self::MYARTJAUB_VENDOR;
40
+                                }
41 41
 
42
-    /**
43
-     * Name of the MyArtJaub modules' vendor
44
-     * @var string MYARTJAUB_VENDOR
45
-     * */
46
-    private const MYARTJAUB_VENDOR = 'jon48';
42
+                                /**
43
+                                 * Name of the MyArtJaub modules' vendor
44
+                                 * @var string MYARTJAUB_VENDOR
45
+                                 * */
46
+                                private const MYARTJAUB_VENDOR = 'jon48';
47 47
 
48
-    /**
49
-     * List all the PSR-4 paths used in MyArtJaub packages autoloading.
50
-     * The returned array is composed of items with the structure:
51
-     *      - array [
52
-     *              0 => Package Name
53
-     *              1 => Array of normalised paths
54
-     *          ]
55
-     *
56
-     * @return array
57
-     */
58
-    public function listMyArtJaubPackagesPaths(): array
59
-    {
60
-        if (getenv('HOME') === false) {
61
-            putenv('HOME=' . Webtrees::DATA_DIR);
62
-        }
48
+                                /**
49
+                                 * List all the PSR-4 paths used in MyArtJaub packages autoloading.
50
+                                 * The returned array is composed of items with the structure:
51
+                                 *      - array [
52
+                                 *              0 => Package Name
53
+                                 *              1 => Array of normalised paths
54
+                                 *          ]
55
+                                 *
56
+                                 * @return array
57
+                                 */
58
+                                public function listMyArtJaubPackagesPaths(): array
59
+                                {
60
+                                if (getenv('HOME') === false) {
61
+                                putenv('HOME=' . Webtrees::DATA_DIR);
62
+                                }
63 63
 
64
-        $composer = Factory::create(new NullIO(), Webtrees::ROOT_DIR . 'composer.json');
64
+                                $composer = Factory::create(new NullIO(), Webtrees::ROOT_DIR . 'composer.json');
65 65
 
66
-        $packages = $composer->getRepositoryManager()
67
-            ->getLocalRepository()
68
-            ->getPackages();
66
+                                $packages = $composer->getRepositoryManager()
67
+                                ->getLocalRepository()
68
+                                ->getPackages();
69 69
 
70
-        /** @var array<PackageInterface> $maj_packages */
71
-        $maj_packages = array();
72
-        foreach ($packages as $package) {
73
-            if ($this->isMyArtJaubPackage($package)) {
74
-                $maj_packages[] = $this->extractPsr4Paths($composer, $package);
75
-            }
76
-        }
70
+                                /** @var array<PackageInterface> $maj_packages */
71
+                                $maj_packages = array();
72
+                                foreach ($packages as $package) {
73
+                                if ($this->isMyArtJaubPackage($package)) {
74
+                                $maj_packages[] = $this->extractPsr4Paths($composer, $package);
75
+                                }
76
+                                }
77 77
 
78
-        return $maj_packages;
79
-    }
78
+                                return $maj_packages;
79
+                                }
80 80
 
81
-    /**
82
-     * Extract and normalise the PSR-4 paths used in a package autoloading.
83
-     * The returned array is a 2-tuple with the structure:
84
-     *      - array [
85
-     *              0 => Package Name
86
-     *              1 => Array of normalised paths
87
-     *          ]
88
-     *
89
-     * @param Composer $composer
90
-     * @param PackageInterface $package
91
-     * @return array
92
-     */
93
-    private function extractPsr4Paths(Composer $composer, PackageInterface $package): array
94
-    {
95
-        $autoload_generator = $composer->getAutoloadGenerator();
81
+                                /**
82
+                                 * Extract and normalise the PSR-4 paths used in a package autoloading.
83
+                                 * The returned array is a 2-tuple with the structure:
84
+                                 *      - array [
85
+                                 *              0 => Package Name
86
+                                 *              1 => Array of normalised paths
87
+                                 *          ]
88
+                                 *
89
+                                 * @param Composer $composer
90
+                                 * @param PackageInterface $package
91
+                                 * @return array
92
+                                 */
93
+                                private function extractPsr4Paths(Composer $composer, PackageInterface $package): array
94
+                                {
95
+                                $autoload_generator = $composer->getAutoloadGenerator();
96 96
 
97
-        $package_map = $autoload_generator->buildPackageMap(
98
-            $composer->getInstallationManager(),
99
-            $composer->getPackage(),
100
-            [$package]
101
-        );
102
-        array_shift($package_map);
103
-        $autoloads = $autoload_generator->parseAutoloads($package_map, $composer->getPackage());
104
-        $psr4_paths = [];
105
-        foreach ($autoloads['psr-4'] as $psr4_ns_paths) {
106
-            foreach ($psr4_ns_paths as $psr4_ns_path) {
107
-                $psr4_paths[] = realpath($psr4_ns_path);
108
-            }
109
-        }
110
-        return [$package, $psr4_paths];
111
-    }
97
+                                $package_map = $autoload_generator->buildPackageMap(
98
+                                $composer->getInstallationManager(),
99
+                                $composer->getPackage(),
100
+                                [$package]
101
+                                );
102
+                                array_shift($package_map);
103
+                                $autoloads = $autoload_generator->parseAutoloads($package_map, $composer->getPackage());
104
+                                $psr4_paths = [];
105
+                                foreach ($autoloads['psr-4'] as $psr4_ns_paths) {
106
+                                foreach ($psr4_ns_paths as $psr4_ns_path) {
107
+                                $psr4_paths[] = realpath($psr4_ns_path);
108
+                                }
109
+                                }
110
+                                return [$package, $psr4_paths];
111
+                                }
112 112
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,10 +58,10 @@
 block discarded – undo
58 58
     public function listMyArtJaubPackagesPaths(): array
59 59
     {
60 60
         if (getenv('HOME') === false) {
61
-            putenv('HOME=' . Webtrees::DATA_DIR);
61
+            putenv('HOME='.Webtrees::DATA_DIR);
62 62
         }
63 63
 
64
-        $composer = Factory::create(new NullIO(), Webtrees::ROOT_DIR . 'composer.json');
64
+        $composer = Factory::create(new NullIO(), Webtrees::ROOT_DIR.'composer.json');
65 65
 
66 66
         $packages = $composer->getRepositoryManager()
67 67
             ->getLocalRepository()
Please login to merge, or discard this patch.