Filippo Bertilotti
9 days ago c52de027ae84a21cdf03c392b29734793bedff6a
commit | author | age
9f6455 1 <?php
DC 2
3
4 use JetBrains\PhpStorm\Pure;
5
6 /**
7  * Class ParamsBase64
8  */
9 class ParamsBase64
10 {
11     /**
12      * @var string
13      */
14     private string $path;
15     /**
16      * @var string
17      */
18     private string $stringValue;
19     /**
20      * @var bool
21      */
22     private bool $encode;
23     /**
24      *
25      */
26     private const PARAMS_BASE_64 = array(
27         "NEW_FILE" => [
28             "file_path" => "./scripts/decoded_files/new_decoded_file.txt",
29             "base64_string" => "Q2lhbyBhIHR1dHRpLCBpbyBzb25vIHVuYSBzdHJpbmdhIGEgY2Fzby4="
30         ],
31         "NEW_RANDOM_BASE64"
32     );
33
34     /**
35      * ParamsBase64 constructor.
36      * @param string $path
37      * @param string $stringValue
38      * @param bool $encode
39      */
40     public function __construct($path = __DIR__ . "\\decoded_files\\new_decoded_file.txt" , $stringValue = "Q2lhbyBhIHR1dHRpLCBpbyBzb25vIHVuYSBzdHJpbmdhIGEgY2Fzby4=",$encode = true)
41     {
42         $this->path = $path;
43         $this->stringValue = $stringValue;
44         $this->encode = $stringValue;
45     }
46
47
48     /**
49      * @param $name
50      * @return mixed
51      */
52     public static function getConst($name)
53     {
54         return constant('self::' . strtoupper($name));
55     }
56
57     /**
58      * @return string
59      */
60     public function getPath(): string
61     {
62         return $this->path;
63     }
64
65     /**
66      * @param string $path
67      */
68     public function setPath(string $path): void
69     {
70         $this->path = $path;
71     }
72
73     /**
74      * @return string stringa base64 o file name in base in base a $this->isEncode()
75      */
76     public function getStringValue(): string
77     {
78         return $this->stringValue;
79     }
80
81     /**
82      * @param string $stringValue
83      */
84     public function setStringValue(string $stringValue): void
85     {
86         $this->stringValue = $stringValue;
87     }
88
89     /**
90      * @return bool
91      */
92     public function isEncode(): bool|string
93     {
94         return $this->encode;
95     }
96
97     /**
98      * @param bool $encode
99      */
100     public function setEncode(bool|string $encode): void
101     {
102         $this->encode = filter_var($encode,FILTER_VALIDATE_BOOL);
103     }
104
105
106 }