TConfig   A
last analyzed

Complexity

Total Complexity 28

Size/Duplication

Total Lines 262
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
eloc 58
c 5
b 0
f 0
dl 0
loc 262
rs 10
wmc 28

26 Methods

Rating   Name   Duplication   Size   Complexity  
A setHeight() 0 4 1
A setTitleHeight() 0 4 1
A setAutoDataType() 0 4 1
A setMainTitle() 0 4 1
A getTitleRow() 0 3 1
A getHeight() 0 3 1
A getFreezePane() 0 3 1
A isAutoDataType() 0 3 1
A setHorizontalCenter() 0 4 1
A getCreator() 0 3 1
A setFreezePane() 0 4 1
A setCreator() 0 4 1
A setTitleRow() 0 4 1
A getMainTitle() 0 3 1
A getFileName() 0 3 1
A setAutoFilter() 0 4 1
A getSheet() 0 3 1
A setFileName() 0 4 1
A setTitleWidth() 0 4 1
A getTitleHeight() 0 3 1
A setPathName() 0 4 1
A getHorizontalCenter() 0 3 1
A setSheet() 0 4 1
A getTitleWidth() 0 3 1
A isAutoFilter() 0 3 1
A getPathName() 0 10 3
1
<?php
2
/**
3
 * @name: TConfig
4
 * @author: JiaMeng <[email protected]>
5
 * @file: Export.php
6
 * @Date: 2024/03/04 10:15
7
 */
8
namespace tinymeng\spreadsheet\Util;
9
10
trait TConfig{
11
12
    /**
13
     * 文件创建者
14
     * @var string 
15
     */
16
    private $creator = 'tinymeng';
17
18
    /**
19
     * 文件名称
20
     * @var
21
     */
22
    private $fileName;
23
24
    /**
25
     * 文件存储位置
26
     * @var string|bool
27
     */
28
    private $pathName = false;
29
30
    /**
31
     * 是否居中
32
     * @var string
33
     */
34
    private $horizontalCenter = true;
35
36
37
    /**
38
     * 定义表头行高
39
     * @var int 常用:22
40
     */
41
    private $titleHeight = null;
42
    
43
    /**
44
     * 定义表头列宽(未设置则自动计算宽度)
45
     * @var int 常用:20
46
     */
47
    private $titleWidth = null;
48
    
49
    /**
50
     * 定义数据行高
51
     * @var int 常用:22
52
     */
53
    private $height = null;
54
    
55
56
    /**
57
     * 自动筛选(是否开启)
58
     * @var bool
59
     */
60
    private $autoFilter = false;
61
62
    /**
63
     * 自动适应文本类型
64
     * @var bool
65
     */
66
    private $autoDataType = true;
67
68
    /**
69
     * 冻结窗格(要冻结的首行首列"B2",false不开启)
70
     * @var string|bool
71
     */
72
    private $freezePane = false;
73
74
    /**
75
     * 当前选中sheet
76
     * @var string|bool
77
     */
78
    private $sheet = 0;
79
80
    /**
81
     * 标题占用行数
82
     * @var int
83
     */
84
    private $title_row = 1;
85
86
    /**
87
     * 报表名称(主标题)
88
     * @var
89
     */
90
    private $mainTitle = '';
91
92
    /**
93
     * @return bool|int|string
94
     */
95
    public function getSheet()
96
    {
97
        return $this->sheet;
98
    }
99
100
    /**
101
     * @param bool|int|string $sheet
102
     */
103
    public function setSheet($sheet)
104
    {
105
        $this->sheet = $sheet;
106
        return $this;
107
    }
108
109
110
    public function getTitleRow(): int
111
    {
112
        return $this->title_row;
113
    }
114
115
    public function setTitleRow(int $title_row)
116
    {
117
        $this->title_row = $title_row;
118
        return $this;
119
    }
120
121
    public function getCreator(): string
122
    {
123
        return $this->creator;
124
    }
125
126
    public function setCreator(string $creator)
127
    {
128
        $this->creator = $creator;
129
        return $this;
130
    }
131
132
    /**
133
     * @return mixed
134
     */
135
    public function getFileName()
136
    {
137
        return $this->fileName;
138
    }
139
140
    /**
141
     * @param mixed $fileName
142
     */
143
    public function setFileName($fileName)
144
    {
145
        $this->fileName = $fileName;
146
        return $this;
147
    }
148
149
    /**
150
     * @return bool|string
151
     */
152
    public function getHorizontalCenter()
153
    {
154
        return $this->horizontalCenter;
155
    }
156
157
    /**
158
     * @param bool|string $horizontalCenter
159
     */
160
    public function setHorizontalCenter($horizontalCenter)
161
    {
162
        $this->horizontalCenter = $horizontalCenter;
0 ignored issues
show
Documentation Bug introduced by
It seems like $horizontalCenter can also be of type boolean. However, the property $horizontalCenter is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
163
        return $this;
164
    }
165
166
    public function getTitleHeight(): int
167
    {
168
        return $this->titleHeight;
169
    }
170
171
    public function setTitleHeight(int $titleHeight)
172
    {
173
        $this->titleHeight = $titleHeight;
174
        return $this;
175
    }
176
177
    public function getTitleWidth(): int
178
    {
179
        return $this->titleWidth;
180
    }
181
182
    public function setTitleWidth(int $titleWidth)
183
    {
184
        $this->titleWidth = $titleWidth;
185
        return $this;
186
    }
187
188
    public function getHeight(): int
189
    {
190
        return $this->height;
191
    }
192
193
    public function setHeight(int $height)
194
    {
195
        $this->height = $height;
196
        return $this;
197
    }
198
199
    public function isAutoFilter(): bool
200
    {
201
        return $this->autoFilter;
202
    }
203
204
    public function setAutoFilter(bool $autoFilter)
205
    {
206
        $this->autoFilter = $autoFilter;
207
        return $this;
208
    }
209
210
    public function isAutoDataType(): bool
211
    {
212
        return $this->autoDataType;
213
    }
214
215
    public function setAutoDataType(bool $autoDataType)
216
    {
217
        $this->autoDataType = $autoDataType;
218
        return $this;
219
    }
220
221
    /**
222
     * @return bool|string
223
     */
224
    public function getFreezePane()
225
    {
226
        return $this->freezePane;
227
    }
228
229
    /**
230
     * @param bool|string $freezePane
231
     */
232
    public function setFreezePane($freezePane)
233
    {
234
        $this->freezePane = $freezePane;
235
        return $this;
236
    }
237
238
    /**
239
     * @param bool|string $pathName
240
     */
241
    public function setPathName($pathName)
242
    {
243
        $this->pathName = $pathName;
244
        return $this;
245
    }
246
247
    /**
248
     * @param $pathName
249
     * @return bool|mixed|string
250
     */
251
    private function getPathName($pathName)
252
    {
253
        if(!empty($pathName)){
254
            return $pathName;
255
        }
256
        if($this->pathName){
257
            return $this->pathName;
258
        }
259
        $pathName = dirname( dirname(dirname(SPREADSHEET_ROOT_PATH))).DIRECTORY_SEPARATOR."public".DIRECTORY_SEPARATOR."export".DIRECTORY_SEPARATOR.date('Ymd').DIRECTORY_SEPARATOR;
260
        return $pathName;
261
    }
262
263
    public function getMainTitle(): string
264
    {
265
        return $this->mainTitle;
266
    }
267
268
    public function setMainTitle(string $mainTitle)
269
    {
270
        $this->mainTitle = $mainTitle;
271
        return $this;
272
    }
273
274
}
275