SwaggerResponseBody   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 7
c 0
b 0
f 0
dl 0
loc 14
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A match() 0 9 3
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