Total Complexity | 11 |
Total Lines | 85 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
7 | class lock { |
||
8 | /** |
||
9 | * Check lock is exist or not |
||
10 | * |
||
11 | * @param string $name |
||
12 | * |
||
13 | * @return bool |
||
14 | */ |
||
15 | public static function exist(string $name): bool { |
||
16 | return file_exists(realpath(settings::$name."$name.lock")); |
||
17 | } |
||
18 | |||
19 | /** |
||
20 | * Set lock(create lock) |
||
21 | * |
||
22 | * @param string $name |
||
23 | * |
||
24 | * @return bool |
||
25 | */ |
||
26 | public static function set(string $name): bool { |
||
27 | return touch(settings::$name."$name.lock"); |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * Save data in lock file and make it local |
||
32 | * |
||
33 | * @param string $name |
||
34 | * @param string $data |
||
35 | * |
||
36 | * @return bool|int |
||
37 | */ |
||
38 | public static function save(string $name, string $data): bool|int { |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Read data from lock |
||
44 | * |
||
45 | * @param string $name |
||
46 | * |
||
47 | * @return bool|string |
||
48 | */ |
||
49 | public static function read(string $name): bool|string { |
||
50 | return file_get_contents(realpath(settings::$name."$name.lock")); |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Get last modify time of lock |
||
55 | * |
||
56 | * @param string $name |
||
57 | * |
||
58 | * @return bool|int |
||
59 | */ |
||
60 | public static function mtime(string $name): bool|int { |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Delete lock |
||
66 | * |
||
67 | * @param string $name |
||
68 | * |
||
69 | * @return bool |
||
70 | */ |
||
71 | public static function delete(string $name): bool { |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * check lock exist or not then delete it |
||
77 | * |
||
78 | * @param string|array $names |
||
79 | * |
||
80 | * @return bool |
||
81 | */ |
||
82 | public static function deleteIfExist (string|array $names): bool { |
||
92 | } |
||
93 | } |