88
99namespace VectorNetworkProject \TheMix \provider ;
1010
11-
1211use pocketmine \utils \Config ;
1312use pocketmine \utils \MainLogger ;
1413use VectorNetworkProject \TheMix \lib \database \Provider ;
@@ -23,38 +22,42 @@ class JSON extends Provider
2322
2423 /**
2524 * JSON constructor.
25+ *
2626 * @param string $xuid
2727 * @param string $file
2828 */
2929 public function __construct (string $ xuid , string $ file )
3030 {
31- $ this ->path = self ::getPath ('datas ' , 'json ' ) . $ xuid . '/ ' ;
32- $ this ->file = $ file . '.json ' ;
31+ $ this ->path = self ::getPath ('datas ' , 'json ' ). $ xuid. '/ ' ;
32+ $ this ->file = $ file. '.json ' ;
3333 }
3434
3535 public function init (array $ data = []): void
3636 {
37- if (!$ this ->hasTable ()) $ this ->createTable ($ data );
37+ if (!$ this ->hasTable ()) {
38+ $ this ->createTable ($ data );
39+ }
3840 }
3941
4042 /**
4143 * @param array $table
44+ *
4245 * @return void
4346 */
4447 public function createTable (array $ table = []): void
4548 {
4649 @mkdir ($ this ->path , 0755 , true );
47- $ config = new Config ($ this ->path . $ this ->file , Config::JSON , $ table );
50+ $ config = new Config ($ this ->path . $ this ->file , Config::JSON , $ table );
4851 $ config ->save ();
49- MainLogger::getLogger ()->debug (" [PROVIDER] Create " .$ this ->file );
52+ MainLogger::getLogger ()->debug (' [PROVIDER] Create ' .$ this ->file );
5053 }
5154
5255 /**
5356 * @return bool
5457 */
5558 public function hasTable (): bool
5659 {
57- return file_exists ($ this ->path . $ this ->file )
60+ return file_exists ($ this ->path . $ this ->file )
5861 ? true
5962 : false ;
6063 }
@@ -64,27 +67,29 @@ public function hasTable(): bool
6467 */
6568 public function deleteTable (): void
6669 {
67- unlink ($ this ->path . $ this ->file );
70+ unlink ($ this ->path . $ this ->file );
6871 }
6972
7073 /**
71- * @param string $key
74+ * @param string $key
7275 * @param bool|mixed $data
7376 */
7477 public function set (string $ key , $ data ): void
7578 {
76- $ config = new Config ($ this ->path . $ this ->file , Config::JSON );
79+ $ config = new Config ($ this ->path . $ this ->file , Config::JSON );
7780 $ config ->set ($ key , $ data );
7881 $ config ->save ();
7982 }
8083
8184 /**
8285 * @param string $key
86+ *
8387 * @return bool|mixed
8488 */
8589 public function get (string $ key )
8690 {
87- $ config = new Config ($ this ->path . $ this ->file , Config::JSON );
91+ $ config = new Config ($ this ->path .$ this ->file , Config::JSON );
92+
8893 return $ config ->get ($ key );
8994 }
9095
@@ -93,7 +98,8 @@ public function get(string $key)
9398 */
9499 public function getAll (): array
95100 {
96- $ config = new Config ($ this ->path . $ this ->file , Config::JSON );
101+ $ config = new Config ($ this ->path .$ this ->file , Config::JSON );
102+
97103 return $ config ->getAll ();
98104 }
99105
@@ -102,29 +108,33 @@ public function getAll(): array
102108 */
103109 public function getKeys (): array
104110 {
105- $ config = new Config ($ this ->path . $ this ->file , Config::JSON );
111+ $ config = new Config ($ this ->path .$ this ->file , Config::JSON );
112+
106113 return $ config ->getAll (true );
107114 }
108115
109116 /**
110117 * @param string $key
118+ *
111119 * @return bool
112120 */
113121 public function exists (string $ key ): bool
114122 {
115- $ config = new Config ($ this ->path . $ this ->file , Config::JSON );
123+ $ config = new Config ($ this ->path .$ this ->file , Config::JSON );
124+
116125 return $ config ->exists ($ key )
117126 ? true
118127 : false ;
119128 }
120129
121130 /**
122131 * @param string $key
132+ *
123133 * @return void
124134 */
125135 public function remove (string $ key ): void
126136 {
127- $ config = new Config ($ this ->path . $ this ->file , Config::JSON );
137+ $ config = new Config ($ this ->path . $ this ->file , Config::JSON );
128138 $ config ->remove ($ key );
129139 }
130140}
0 commit comments