1 <?php
2 
3 
4 namespace ComboStrap\Meta\Form;
5 
6 
7 class FormMetaTab
8 {
9     private $name;
10     /**
11      * @var string
12      */
13     private $label;
14     /**
15      * @var int
16      */
17     private $widthField;
18     /**
19      * @var int
20      */
21     private $widthLabel;
22 
23 
24     /**
25      * FormTab constructor.
26      */
27     public function __construct($tabName)
28     {
29         $this->name = $tabName;
30     }
31 
32     public static function create(string $tabName): FormMetaTab
33     {
34         return new FormMetaTab($tabName);
35     }
36 
37     public function setLabel(string $label): FormMetaTab
38     {
39         $this->label = $label;
40         return $this;
41     }
42 
43     /**
44      * @param int $width2 - the width of the field column
45      */
46     public function setWidthField(int $width): FormMetaTab
47     {
48         $this->widthField = $width;
49         return $this;
50     }
51     public function setWidthLabel(int $width): FormMetaTab
52     {
53         $this->widthLabel = $width;
54         return $this;
55     }
56 
57     public function getName()
58     {
59         return $this->name;
60     }
61 
62     public function toAssociativeArray(): array
63     {
64         $array["name"]= $this->name;
65         if(!blank($this->label)) {
66             $array["label"] = $this->label;
67         }
68         if(!blank($this->widthField)) {
69             $array["width-field"] = $this->widthField;
70         }
71         if(!blank($this->widthLabel)) {
72             $array["width-label"] = $this->widthLabel;
73         }
74         return $array;
75     }
76 }
77