ConfigMirror::getPublicMirror()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Satis;
4
5
use App\Satis\Collections\PackageCollection;
6
use App\Satis\Collections\RepositoryCollection;
7
use App\Satis\Model\Repository;
8
use JMS\Serializer\Serializer;
9
10
/**
11
 * @author Lukas Homza <[email protected]>
12
 */
13
class ConfigMirror {
14
    /** @var \App\Satis\Model\ConfigLock */
15
    protected $serializer;
16
17
	/**
18
     * ConfigMirror constructor.
19
     * @param \JMS\Serializer\Serializer $serializer
20
     */
21
    public function __construct(Serializer $serializer) {
22
        $this->serializer = $serializer;
0 ignored issues
show
Documentation Bug introduced by
It seems like $serializer of type object<JMS\Serializer\Serializer> is incompatible with the declared type object<App\Satis\Model\ConfigLock> of property $serializer.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
23
    }
24
25
	/**
26
     * @param string $config
27
     * @return string
28
     */
29
    public function getPublicMirror($config) {
30
        /** @var \App\Satis\Model\Config $publicConfig */
31
        $publicConfig = $this->serializer->deserialize(
0 ignored issues
show
Bug introduced by
The method deserialize() does not seem to exist on object<App\Satis\Model\ConfigLock>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
            $config,
33
            'App\Satis\Model\Config',
34
            'json'
35
        );
36
37
        $repository = new Repository();
38
        $repository->setType('composer');
39
        $repository->setUrl('https://packagist.org/');
40
41
        $homepage = $publicConfig->getHomepage();
42
43
        $publicConfig->setHomepage(rtrim($homepage, '/') . '/' . config('satis.public_repository'))
44
            ->setRequireAll(false)
45
            ->setRepositories(new RepositoryCollection([$repository]));
46
47
        return $this->serializer->serialize($publicConfig, 'json');
0 ignored issues
show
Bug introduced by
The method serialize() does not seem to exist on object<App\Satis\Model\ConfigLock>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
    }
49
50
    /**
51
     * @param string $config
52
     * @return string
53
     */
54
    public function getPrivateMirror($config) {
55
        /** @var \App\Satis\Model\Config $privateConfig */
56
        $privateConfig = $this->serializer->deserialize(
0 ignored issues
show
Bug introduced by
The method deserialize() does not seem to exist on object<App\Satis\Model\ConfigLock>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57
            $config,
58
            'App\Satis\Model\Config',
59
            'json'
60
        );
61
62
        $homepage = $privateConfig->getHomepage();
63
64
        $privateConfig->setHomepage(rtrim($homepage, '/') . '/' . config('satis.private_repository'))
65
            ->setRequireAll(true)
66
            ->setProviders(true)
67
            ->setPackages(new PackageCollection());
68
69
        return $this->serializer->serialize($privateConfig, 'json');
0 ignored issues
show
Bug introduced by
The method serialize() does not seem to exist on object<App\Satis\Model\ConfigLock>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
70
    }
71
}
72