Completed
Branch v2 (f7f89f)
by Pieter
04:28
created

PhpPrimitive   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 14
c 1
b 0
f 1
dl 0
loc 24
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSchemaForFilter() 0 12 4
1
<?php
2
namespace W2w\Lib\Apie\ValueObjects;
3
4
use erasys\OpenApi\Spec\v3\Schema;
5
6
class PhpPrimitive implements ValueObjectInterface
7
{
8
    const STRING = 'STRING';
9
10
    const BOOL = 'BOOL';
11
12
    const INT = 'INT';
13
14
    const FLOAT = 'FLOAT';
15
16
    use StringEnumTrait;
17
18
    public function getSchemaForFilter(): Schema
19
    {
20
        switch ($this->toNative()) {
21
            case self::BOOL:
22
                return new Schema(['type' => 'boolean']);
23
            case self::INT:
24
                return new Schema(['type' => 'number', 'format' => 'int32']);
25
            case self::FLOAT:
26
                return new Schema(['type' => 'number', 'format' => 'double']);
27
        }
28
29
        return new Schema(['type' => 'string', 'minimum' => 1]);
30
    }
31
32
}
33