1 | <?php |
||
6 | |||
7 | class ConfigurationFileUpdater |
||
8 | { |
||
9 | /** @var PlainValueUpdater */ |
||
10 | private $plainValueUpdater; |
||
11 | /** @var KeywordListUpdater */ |
||
12 | private $keywordListUpdater; |
||
13 | /** @var ListUpdater */ |
||
14 | private $listUpdater; |
||
15 | /** @var AuthorListUpdater */ |
||
16 | private $authorListUpdater; |
||
17 | 1 | ||
18 | public function __construct( |
||
29 | |||
30 | /** |
||
31 | * @param ConfigurationFile[] $configurationList |
||
32 | * |
||
33 | * @return ConfigurationFile |
||
34 | 1 | */ |
|
35 | public function update(array $configurationList) |
||
46 | |||
47 | |||
48 | /** |
||
49 | * @param ConfigurationFile $baseConfigurationFile |
||
50 | * @param ConfigurationFile $newConfigurationFile |
||
51 | * |
||
52 | * @return ConfigurationFile |
||
53 | 1 | */ |
|
54 | public function merge(ConfigurationFile $baseConfigurationFile, ConfigurationFile $newConfigurationFile) |
||
67 | 1 | ||
68 | 1 | protected function mergeConfiguration(Configuration $baseConfiguration, Configuration $newConfiguration) |
|
69 | 1 | { |
|
70 | 1 | return new Configuration( |
|
71 | 1 | $this->plainValueUpdater->update( |
|
72 | 1 | $newConfiguration->getPackageName(), |
|
73 | 1 | $baseConfiguration->getPackageName() |
|
74 | 1 | ), |
|
75 | 1 | $this->plainValueUpdater->update( |
|
76 | 1 | $newConfiguration->getType(), |
|
77 | 1 | $baseConfiguration->getType() |
|
78 | 1 | ), |
|
79 | 1 | $this->plainValueUpdater->update( |
|
80 | 1 | $newConfiguration->getLicense(), |
|
81 | 1 | $baseConfiguration->getLicense() |
|
82 | 1 | ), |
|
83 | 1 | $this->plainValueUpdater->update( |
|
84 | 1 | $newConfiguration->getPackageVersion(), |
|
85 | 1 | $baseConfiguration->getPackageVersion() |
|
86 | 1 | ), |
|
87 | 1 | $this->plainValueUpdater->update( |
|
88 | 1 | $newConfiguration->getDescription(), |
|
89 | 1 | $baseConfiguration->getDescription() |
|
90 | 1 | ), |
|
91 | 1 | $this->keywordListUpdater->update( |
|
92 | 1 | $newConfiguration->getKeywordList(), |
|
93 | 1 | $baseConfiguration->getKeywordList() |
|
94 | 1 | ), |
|
95 | 1 | $this->authorListUpdater->update($newConfiguration->getAuthorList(), $baseConfiguration->getAuthorList()), |
|
96 | 1 | $this->listUpdater->update( |
|
97 | 1 | $newConfiguration->getProvidedPackageList(), |
|
98 | 1 | $baseConfiguration->getProvidedPackageList() |
|
99 | 1 | ), |
|
100 | 1 | $this->listUpdater->update( |
|
101 | 1 | $newConfiguration->getSuggestedPackageList(), |
|
102 | 1 | $baseConfiguration->getSuggestedPackageList() |
|
103 | 1 | ), |
|
104 | 1 | $this->listUpdater->update($newConfiguration->getSupportList(), $baseConfiguration->getSupportList()), |
|
105 | $this->listUpdater->update($newConfiguration->getAutoloadList(), $baseConfiguration->getAutoloadList()), |
||
106 | $this->listUpdater->update( |
||
107 | $newConfiguration->getAutoloadDevList(), |
||
127 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: