forked from 1forU/string-encoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptions.php
More file actions
73 lines (57 loc) · 1.59 KB
/
Copy pathOptions.php
File metadata and controls
73 lines (57 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
declare(strict_types=1);
namespace StringEncoder;
use StringEncoder\Contracts\DTO\EncodingDTOInterface;
use StringEncoder\Contracts\OptionsInterface;
use StringEncoder\DTO\EncodingDTO;
class Options implements OptionsInterface
{
/**
* @var EncodingDTO
*/
private $defaultTargetEncoding;
/**
* @var bool
*/
private $removeUTF8BOM = false;
/**
* @var bool
*/
private $caseSensitiveEncoding = true;
/**
* @throws Exceptions\InvalidEncodingException
*/
public function setDefaultTargetEncoding(string $defaultTargetEncoding): OptionsInterface
{
$this->defaultTargetEncoding = EncodingDTO::makeFromString($defaultTargetEncoding, null, $this);
return $this;
}
/**
* @throws Exceptions\InvalidEncodingException
*/
public function getDefaultTargetEncoding(): EncodingDTOInterface
{
if ($this->defaultTargetEncoding === null) {
$this->defaultTargetEncoding = EncodingDTO::makeFromString('UTF-8');
}
return $this->defaultTargetEncoding;
}
public function setRemoveUTF8BOM(bool $remove): OptionsInterface
{
$this->removeUTF8BOM = $remove;
return $this;
}
public function isRemoveUTF8BOM(): bool
{
return $this->removeUTF8BOM;
}
public function setCaseSensitiveEncoding(bool $caseSensitive): OptionsInterface
{
$this->caseSensitiveEncoding = $caseSensitive;
return $this;
}
public function isCaseSensitiveEncoding(): bool
{
return $this->caseSensitiveEncoding;
}
}