UserEventMenuClickMiniProgram::isPage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: hugh.li
5
 * Date: 2022/2/24
6
 * Time: 17:35
7
 */
8
9
namespace HughCube\Laravel\WeChat\Message\Event;
10
11
use HughCube\Laravel\WeChat\Contracts\Message\Event\UserEventMenuClickMiniProgram as Contract;
12
use Illuminate\Support\Str;
13
14
class UserEventMenuClickMiniProgram extends Event implements Contract
15
{
16
    public function getPage(): string
17
    {
18
        return $this->getEventKey();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getEventKey() could return the type array|null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
19
    }
20
21
    public function getMenuId(): string
22
    {
23
        return $this->getMessage('MenuId');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getMessage('MenuId') could return the type array|null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
24
    }
25
26
    public function isMenuId(...$ids): bool
27
    {
28
        foreach ($ids as $id) {
29
            if ($id == $this->getMenuId()) {
30
                return true;
31
            }
32
        }
33
        return false;
34
    }
35
36
    public function isPage($pattern): bool
37
    {
38
        return Str::is($pattern, $this->getPage());
39
    }
40
}
41