forked from zircote/swagger-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCleanUnmerged.php
33 lines (28 loc) · 880 Bytes
/
CleanUnmerged.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php declare(strict_types=1);
/**
* @license Apache 2.0
*/
namespace OpenApi\Processors;
use OpenApi\Analysis;
class CleanUnmerged
{
public function __invoke(Analysis $analysis)
{
$split = $analysis->split();
$merged = $split->merged->annotations;
$unmerged = $split->unmerged->annotations;
foreach ($analysis->annotations as $annotation) {
if (property_exists($annotation, '_unmerged')) {
foreach ($annotation->_unmerged as $i => $item) {
if ($merged->contains($item)) {
unset($annotation->_unmerged[$i]); // Property was merged
}
}
}
}
$analysis->openapi->_unmerged = [];
foreach ($unmerged as $annotation) {
$analysis->openapi->_unmerged[] = $annotation;
}
}
}