-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathResources.php
37 lines (26 loc) · 1.02 KB
/
Resources.php
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
<?php
declare(strict_types=1);
final class Resources {
private static $instance = null;
private $fileName;
private $fileStream;
private $constants;
private function __construct()
{
$this->fileName = "Constants.json";
$this->fileStream = fopen($this->fileName, "r+") or die("Unable to open/create file");
$this->constants = json_decode(fread($this->fileStream, filesize($this->fileName)), true);
}
public function getLength(): int {return $this->constants["length"];}
public function getDigits(): int {return $this->constants["digits"];}
public function getCapitals(): int {return $this->constants["capitals"];}
public function getLowers(): int {return $this->constants["lowers"];}
public function getSpecials(): int {return $this->constants["specials"];}
static function getInstance(): Resources {
self::$instance = self::$instance == null?
new Resources() : self::$instance;
return self::$instance;
}
public function __destruct() {fclose($this->fileStream);}
}
?>