-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy path2_after.php
68 lines (57 loc) · 1.18 KB
/
2_after.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
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
<?php
namespace Mpug;
class Foo
{
public $state = 'stop';
private function isAdmin(): bool
{
/*
가벼운 코드만 있음
*/
return false;
}
private function isOwner(): bool
{
/*
엄청 무거운 코드가 있음
*/
return true;
}
private function getData(): array
{
/*
엄청 무거운 코드가 있음
*/
return [
'n' => 5,
'm' => 7,
];
}
public function exec()
{
/*
관리자는 무조건 run
소유자는 데이터의 값이 유효하면 run
그 외는 stop
*/
$fn_foo = function (): string {
if ($this->isAdmin()) {
return 'run';
}
if (!$this->isOwner()) {
return 'stop';
}
$data = $this->getData();
if ($data['n'] <= 9 && $data['m'] >= 3) {
return 'run';
} else {
return 'stop';
}
};
$this->state = $fn_foo();
}
}
echo "HI\n";
$foo = new Foo();
$foo->exec();
echo "{$foo->state}\n";