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\UserMessageText as Contract; |
||||
12 | use HughCube\PUrl\HUrl; |
||||
13 | use Illuminate\Support\Str; |
||||
14 | |||||
15 | class UserMessageText extends Event implements Contract |
||||
16 | { |
||||
17 | public function getContent($trim = true): string |
||||
18 | { |
||||
19 | $content = $this->getMessage('Content'); |
||||
20 | |||||
21 | return $trim ? trim($content) : $content; |
||||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() It seems like
$content can also be of type array and null ; however, parameter $string of trim() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
22 | } |
||||
23 | |||||
24 | public function is($pattern, $trim = true): bool |
||||
25 | { |
||||
26 | return Str::is($pattern, $this->getContent($trim)); |
||||
27 | } |
||||
28 | |||||
29 | public function eq($string, $trim = true): bool |
||||
30 | { |
||||
31 | return $string === $this->getContent($trim); |
||||
32 | } |
||||
33 | |||||
34 | public function contains($needles, $ignoreCase = false, $trim = true): bool |
||||
35 | { |
||||
36 | return Str::contains($this->getContent($trim), $needles, $ignoreCase); |
||||
0 ignored issues
–
show
The call to
Illuminate\Support\Str::contains() has too many arguments starting with $ignoreCase .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. ![]() |
|||||
37 | } |
||||
38 | |||||
39 | public function getUrl(): ?HUrl |
||||
40 | { |
||||
41 | return HUrl::parse($this->getContent()); |
||||
42 | } |
||||
43 | } |
||||
44 |