Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Code Lines | 36 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
31 | protected function getFormFieldAttributesTab($record, $context = []) |
||
32 | { |
||
33 | /** @var Tab $tab */ |
||
34 | $tab = parent::getFormFieldAttributesTab($record, $context); |
||
35 | |||
36 | $alignments = array( |
||
37 | 'leftAlone' => _t('AssetAdmin.AlignmentLeftAlone', 'On the left, on its own.'), |
||
38 | 'center' => _t('AssetAdmin.AlignmentCenter', 'Centered, on its own.'), |
||
39 | 'left' => _t('AssetAdmin.AlignmentLeft', 'On the left, with text wrapping around.'), |
||
40 | 'right' => _t('AssetAdmin.AlignmentRight', 'On the right, with text wrapping around.'), |
||
41 | ); |
||
42 | |||
43 | $tab->push( |
||
44 | DropdownField::create('Alignment', _t('AssetAdmin.Alignment', 'Alignment'), $alignments) |
||
45 | ); |
||
46 | $tab->push( |
||
47 | FieldGroup::create( |
||
48 | _t('AssetAdmin.ImageSpecs', 'Dimensions'), |
||
49 | TextField::create( |
||
50 | 'InsertWidth', |
||
51 | _t('AssetAdmin.ImageWidth', 'Width') |
||
52 | ) |
||
53 | ->setMaxLength(5) |
||
54 | ->addExtraClass('flexbox-area-grow'), |
||
55 | TextField::create( |
||
56 | 'InsertHeight', |
||
57 | _t('AssetAdmin.ImageHeight', 'Height') |
||
58 | ) |
||
59 | ->setMaxLength(5) |
||
60 | ->addExtraClass('flexbox-area-grow') |
||
61 | ) |
||
62 | ->addExtraClass('fieldgroup--fill-width') |
||
63 | ->setName('Dimensions') |
||
64 | ); |
||
65 | |||
66 | $tab->insertBefore( |
||
67 | 'Caption', |
||
68 | TextField::create('AltText', _t('AssetAdmin.AltText', 'Alternative text (alt)')) |
||
69 | ->setDescription(_t( |
||
70 | 'AssetAdmin.AltTextDescription', |
||
71 | 'Shown to screen readers or if image can\'t be displayed' |
||
72 | )) |
||
73 | ); |
||
74 | $tab->insertAfter( |
||
75 | 'AltText', |
||
76 | TextField::create('TitleTooltip', _t('AssetAdmin.TitleTooltip', 'Title text (tooltip)')) |
||
77 | ->setDescription(_t('AssetAdmin.TitleTooltipDescription', 'For additional information about the image')) |
||
78 | ->setValue($record->Title) |
||
79 | ); |
||
80 | |||
81 | return $tab; |
||
82 | } |
||
83 | |||
128 |