SwaggerResponseBody::match()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 9
c 0
b 0
f 0
rs 10
cc 3
nc 3
nop 1
1
<?php
2
3
namespace ByJG\ApiTools\Swagger;
4
5
use ByJG\ApiTools\Base\Body;
6
use ByJG\ApiTools\Exception\NotMatchedException;
7
8
class SwaggerResponseBody extends Body
9
{
10
    /**
11
     * @inheritDoc
12
     */
13
    public function match(mixed $body): bool
14
    {
15
        if (!isset($this->structure['schema'])) {
16
            if (!empty($body)) {
17
                throw new NotMatchedException("Expected empty body for " . $this->name);
18
            }
19
            return true;
20
        }
21
        return $this->matchSchema($this->name, $this->structure['schema'], $body) ?? false;
22
    }
23
}
24