AdminPdfLetterFieldsFormTrait   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 18
dl 0
loc 43
ccs 0
cts 23
cp 0
rs 10
c 1
b 1
f 0
wmc 9

6 Methods

Rating   Name   Duplication   Size   Complexity  
A initTextTransformElement() 0 5 2
A initGenericElements() 0 7 1
A initColorElement() 0 3 1
A initAlignElement() 0 5 2
A initSizeElement() 0 5 2
A initPositionElements() 0 4 1
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