Passed
Push — master ( 4474a4...77f770 )
by ma
03:21
created

TConfig::setMainTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 2
nc 1
nop 1
dl 0
loc 4
c 2
b 0
f 0
cc 1
rs 10
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
     * @var
88
     */
89
    private $mainTitle = '';
90
91
    /**
92
     * @return bool|int|string
93
     */
94
    public function getSheet()
95
    {
96
        return $this->sheet;
97
    }
98
99
    /**
100
     * @param bool|int|string $sheet
101
     */
102
    public function setSheet($sheet)
103
    {
104
        $this->sheet = $sheet;
105
        return $this;
106
    }
107
108
109
    public function getTitleRow(): int
110
    {
111
        return $this->title_row;
112
    }
113
114
    public function setTitleRow(int $title_row)
115
    {
116
        $this->title_row = $title_row;
117
        return $this;
118
    }
119
120
    public function getCreator(): string
121
    {
122
        return $this->creator;
123
    }
124
125
    public function setCreator(string $creator)
126
    {
127
        $this->creator = $creator;
128
        return $this;
129
    }
130
131
    /**
132
     * @return mixed
133
     */
134
    public function getFileName()
135
    {
136
        return $this->fileName;
137
    }
138
139
    /**
140
     * @param mixed $fileName
141
     */
142
    public function setFileName($fileName)
143
    {
144
        $this->fileName = $fileName;
145
        return $this;
146
    }
147
148
    /**
149
     * @return bool|string
150
     */
151
    public function getHorizontalCenter()
152
    {
153
        return $this->horizontalCenter;
154
    }
155
156
    /**
157
     * @param bool|string $horizontalCenter
158
     */
159
    public function setHorizontalCenter($horizontalCenter)
160
    {
161
        $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...
162
        return $this;
163
    }
164
165
    public function getTitleHeight(): int
166
    {
167
        return $this->titleHeight;
168
    }
169
170
    public function setTitleHeight(int $titleHeight)
171
    {
172
        $this->titleHeight = $titleHeight;
173
        return $this;
174
    }
175
176
    public function getTitleWidth(): int
177
    {
178
        return $this->titleWidth;
179
    }
180
181
    public function setTitleWidth(int $titleWidth)
182
    {
183
        $this->titleWidth = $titleWidth;
184
        return $this;
185
    }
186
187
    public function getHeight(): int
188
    {
189
        return $this->height;
190
    }
191
192
    public function setHeight(int $height)
193
    {
194
        $this->height = $height;
195
        return $this;
196
    }
197
198
    public function isAutoFilter(): bool
199
    {
200
        return $this->autoFilter;
201
    }
202
203
    public function setAutoFilter(bool $autoFilter)
204
    {
205
        $this->autoFilter = $autoFilter;
206
        return $this;
207
    }
208
209
    public function isAutoDataType(): bool
210
    {
211
        return $this->autoDataType;
212
    }
213
214
    public function setAutoDataType(bool $autoDataType)
215
    {
216
        $this->autoDataType = $autoDataType;
217
        return $this;
218
    }
219
220
    /**
221
     * @return bool|string
222
     */
223
    public function getFreezePane()
224
    {
225
        return $this->freezePane;
226
    }
227
228
    /**
229
     * @param bool|string $freezePane
230
     */
231
    public function setFreezePane($freezePane)
232
    {
233
        $this->freezePane = $freezePane;
234
        return $this;
235
    }
236
237
    /**
238
     * @param bool|string $pathName
239
     */
240
    public function setPathName($pathName)
241
    {
242
        $this->pathName = $pathName;
243
        return $this;
244
    }
245
246
    /**
247
     * @param $pathName
248
     * @return bool|mixed|string
249
     */
250
    private function getPathName($pathName)
251
    {
252
        if(!empty($pathName)){
253
            return $pathName;
254
        }
255
        if($this->pathName){
256
            return $this->pathName;
257
        }
258
        $pathName = dirname( dirname(dirname(SPREADSHEET_ROOT_PATH))).DIRECTORY_SEPARATOR."public".DIRECTORY_SEPARATOR."export".DIRECTORY_SEPARATOR.date('Ymd').DIRECTORY_SEPARATOR;
259
        return $pathName;
260
    }
261
262
    public function getMainTitle(): string
263
    {
264
        return $this->mainTitle;
265
    }
266
267
    public function setMainTitle(string $mainTitle)
268
    {
269
        $this->mainTitle = $mainTitle;
270
        return $this;
271
    }
272
273
}
274