Skip to content

Commit 432697b

Browse files
committed
Tweak open-platform events.
1 parent eb76304 commit 432697b

File tree

5 files changed

+69
-48
lines changed

5 files changed

+69
-48
lines changed

src/Events/OpenPlatform/Authorized.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@
1111

1212
namespace Overtrue\LaravelWeChat\Events\OpenPlatform;
1313

14-
class Authorized
14+
/**
15+
* @method string getAppId()
16+
* @method string getCreateTime()
17+
* @method string getInfoType()
18+
* @method string getAuthorizerAppid()
19+
* @method string getAuthorizationCode()
20+
* @method string getAuthorizationCodeExpiredTime()
21+
* @method string getPreAuthCode()
22+
*/
23+
class Authorized extends OpenPlatformEvent
1524
{
16-
public $payload;
17-
18-
/**
19-
* Create a new event instance.
20-
*
21-
* @param array $payload
22-
*/
23-
public function __construct(array $payload)
24-
{
25-
$this->payload = $payload;
26-
}
2725
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the overtrue/laravel-wechat.
5+
*
6+
* (c) overtrue <[email protected]>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
namespace Overtrue\LaravelWeChat\Events\OpenPlatform;
13+
14+
abstract class OpenPlatformEvent
15+
{
16+
/**
17+
* @var array
18+
*/
19+
public $payload;
20+
21+
/**
22+
* Create a new event instance.
23+
*
24+
* @param array $payload
25+
*/
26+
public function __construct(array $payload)
27+
{
28+
$this->payload = $payload;
29+
}
30+
31+
public function __call($name, $args)
32+
{
33+
return $this->payload[substr($name, 3)] ?? null;
34+
}
35+
}

src/Events/OpenPlatform/Unauthorized.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,12 @@
1111

1212
namespace Overtrue\LaravelWeChat\Events\OpenPlatform;
1313

14-
class Unauthorized
14+
/**
15+
* @method string getAppId()
16+
* @method string getCreateTime()
17+
* @method string getInfoType()
18+
* @method string getAuthorizerAppid()
19+
*/
20+
class Unauthorized extends OpenPlatformEvent
1521
{
16-
public $payload;
17-
18-
/**
19-
* Create a new event instance.
20-
*
21-
* @param array $payload
22-
*/
23-
public function __construct(array $payload)
24-
{
25-
$this->payload = $payload;
26-
}
2722
}

src/Events/OpenPlatform/UpdateAuthorized.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@
1111

1212
namespace Overtrue\LaravelWeChat\Events\OpenPlatform;
1313

14-
class UpdateAuthorized
14+
/**
15+
* @method string getAppId()
16+
* @method string getCreateTime()
17+
* @method string getInfoType()
18+
* @method string getAuthorizerAppid()
19+
* @method string getAuthorizationCode()
20+
* @method string getAuthorizationCodeExpiredTime()
21+
* @method string getPreAuthCode()
22+
*/
23+
class UpdateAuthorized extends OpenPlatformEvent
1524
{
16-
public $payload;
17-
18-
/**
19-
* Create a new event instance.
20-
*
21-
* @param array $payload
22-
*/
23-
public function __construct(array $payload)
24-
{
25-
$this->payload = $payload;
26-
}
2725
}

src/Events/OpenPlatform/VerifyTicketRefreshed.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,12 @@
1111

1212
namespace Overtrue\LaravelWeChat\Events\OpenPlatform;
1313

14-
class VerifyTicketRefreshed
14+
/**
15+
* @method string getAppId()
16+
* @method string getCreateTime()
17+
* @method string getInfoType()
18+
* @method string getComponentVerifyTicket()
19+
*/
20+
class VerifyTicketRefreshed extends OpenPlatformEvent
1521
{
16-
public $payload;
17-
18-
/**
19-
* Create a new event instance.
20-
*
21-
* @param array $payload
22-
*/
23-
public function __construct(array $payload)
24-
{
25-
$this->payload = $payload;
26-
}
2722
}

0 commit comments

Comments
 (0)