AdminPdfLetterFieldsFormTrait::initSizeElement()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 6
rs 10
c 1
b 1
f 0
1
<?php
2
3
namespace ByTIC\DocumentGenerator\PdfLetters\Forms\Fields;
4
5
use ByTIC\DocumentGenerator\PdfLetters\Models\Fields\Attributes\TextTransform;
6
7
/**
8
 * Trait AdminPdfLetterFieldsControllerTrait
9
 * @package ByTIC\DocumentGenerator\PdfLetters\Forms\Fields
10
 */
11
trait AdminPdfLetterFieldsFormTrait
12
{
13
    protected function initGenericElements()
14
    {
15
        $this->initPositionElements();
16
        $this->initSizeElement();
17
        $this->initColorElement();
18
        $this->initAlignElement();
19
        $this->initTextTransformElement();
20
    }
21
22
    protected function initPositionElements()
23
    {
24
        $this->addInput('x', 'X', true);
0 ignored issues
show
Bug introduced by
It seems like addInput() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        $this->/** @scrutinizer ignore-call */ 
25
               addInput('x', 'X', true);
Loading history...
25
        $this->addInput('y', 'Y', true);
26
    }
27
28
    protected function initColorElement()
29
    {
30
        $this->addInput('color', translator()->trans('color'), false);
31
    }
32
33
    protected function initSizeElement()
34
    {
35
        $this->addSelect('size', translator()->trans('size'), true);
0 ignored issues
show
Bug introduced by
It seems like addSelect() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
        $this->/** @scrutinizer ignore-call */ 
36
               addSelect('size', translator()->trans('size'), true);
Loading history...
36
        foreach (range(9, 500) as $size) {
37
            $this->size->addOption($size, $size);
38
        }
39
    }
40
41
    protected function initAlignElement()
42
    {
43
        $this->addSelect('align', translator()->trans('align'), true);
44
        foreach (['left', 'center', 'right'] as $option) {
45
            $this->getElement('align')->addOption($option, translator()->trans($option));
0 ignored issues
show
Bug introduced by
It seems like getElement() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

45
            $this->/** @scrutinizer ignore-call */ 
46
                   getElement('align')->addOption($option, translator()->trans($option));
Loading history...
46
        }
47
    }
48
49
    protected function initTextTransformElement()
50
    {
51
        $this->addSelect(TextTransform::NAME, translator()->trans('text-transform'), true);
52
        foreach (TextTransform::OPTIONS as $option) {
53
            $this->getElement(TextTransform::NAME)->addOption($option, translator()->trans($option));
54
        }
55
    }
56
}
57