Completed
Push — master ( 814431...bcdc84 )
by Viacheslav
10:46 queued 15s
created

BuilderOptions::setupBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 8
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Swaggest\JsonCli\GenPhp;
4
5
use Swaggest\PhpCodeBuilder\JsonSchema\PhpBuilder;
6
use Yaoi\Command\Option;
7
8
trait BuilderOptions
9
{
10
    /** @var bool */
11
    public $setters = false;
12
    /** @var bool */
13
    public $getters = false;
14
    /** @var bool */
15
    public $noEnumConst = false;
16
17
    /** @var bool */
18
    public $declarePropertyDefaults = false;
19
20
    /** @var bool */
21
    public $buildAdditionalPropertiesAccessors = false;
22
23
    /**
24
     * @param \stdClass|static $options
25
     */
26
    static public function setupBuilderOptions($options)
27
    {
28
        $options->setters = Option::create()->setDescription('Build setters');
0 ignored issues
show
Documentation Bug introduced by
It seems like Yaoi\Command\Option::cre...iption('Build setters') of type Yaoi\Command\Option is incompatible with the declared type boolean of property $setters.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
29
        $options->getters = Option::create()->setDescription('Build getters');
0 ignored issues
show
Documentation Bug introduced by
It seems like Yaoi\Command\Option::cre...iption('Build getters') of type Yaoi\Command\Option is incompatible with the declared type boolean of property $getters.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
30
        $options->noEnumConst = Option::create()
0 ignored issues
show
Documentation Bug introduced by
It seems like Yaoi\Command\Option::cre...for enum/const values') of type Yaoi\Command\Option is incompatible with the declared type boolean of property $noEnumConst.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
31
            ->setDescription('Do not create constants for enum/const values');
32
33
        $options->declarePropertyDefaults = Option::create()
0 ignored issues
show
Documentation Bug introduced by
It seems like Yaoi\Command\Option::cre...initialize properties') of type Yaoi\Command\Option is incompatible with the declared type boolean of property $declarePropertyDefaults.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
34
            ->setDescription('Use default values to initialize properties');
35
36
        $options->buildAdditionalPropertiesAccessors = Option::create()
0 ignored issues
show
Documentation Bug introduced by
It seems like Yaoi\Command\Option::cre... additionalProperties') of type Yaoi\Command\Option is incompatible with the declared type boolean of property $buildAdditionalPropertiesAccessors.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
37
            ->setDescription('Build accessors for additionalProperties');
38
    }
39
40
    protected function setupBuilder(PhpBuilder $builder)
41
    {
42
        $builder->buildSetters = $this->setters;
43
        $builder->buildGetters = $this->getters;
44
45
        $builder->makeEnumConstants = !$this->noEnumConst;
46
        $builder->declarePropertyDefaults = $this->declarePropertyDefaults;
47
        $builder->buildAdditionalPropertyMethodsOnTrue = $this->buildAdditionalPropertiesAccessors;
48
    }
49
50
}