Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applied fixes from StyleCI #195

Merged
merged 1 commit into from
Jan 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/Broadcast/Broadcast.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* @link https://github.com/overtrue
* @link http://overtrue.me
*/

namespace EasyWeChat\Broadcast;

use EasyWeChat\Core\AbstractAPI;
Expand Down Expand Up @@ -49,8 +48,8 @@ class Broadcast extends AbstractAPI
* Send a message.
*
* @param string $msgType message type
* @param mixed $message message
* @param mixed $to
* @param mixed $message message
* @param mixed $to
*
* @return mixed
*/
Expand All @@ -67,7 +66,7 @@ public function send($msgType, $message, $to = null)
* Preview a message.
*
* @param string $msgType message type
* @param mixed $message message
* @param mixed $message message
* @param string $to
* @param string $by
*
Expand Down Expand Up @@ -115,7 +114,7 @@ public function status($msgId)
/**
* post request.
*
* @param string $url
* @param string $url
* @param array|string $options
*
* @return array|bool
Expand Down
9 changes: 4 additions & 5 deletions src/Broadcast/MessageBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* @link https://github.com/overtrue
* @link http://overtrue.me
*/

namespace EasyWeChat\Broadcast;

use EasyWeChat\Core\Exceptions\InvalidArgumentException;
Expand Down Expand Up @@ -85,7 +84,7 @@ class MessageBuilder
*/
public function msgType($msgType)
{
if (!in_array($msgType, $this->msgTypes)) {
if (!in_array($msgType, $this->msgTypes, true)) {
throw new InvalidArgumentException('This message type not exist.');
}

Expand Down Expand Up @@ -140,9 +139,9 @@ public function build()
}

// 群发视频消息给用户列表时,视频消息格式需要另外处理,具体见文档
if (isset($this->to) && is_array($this->to) && $this->msgType == Broadcast::MSG_TYPE_VIDEO) {
if (isset($this->to) && is_array($this->to) && $this->msgType === Broadcast::MSG_TYPE_VIDEO) {
$this->msgType = 'video';
} elseif ($this->msgType == Broadcast::MSG_TYPE_VIDEO) {
} elseif ($this->msgType === Broadcast::MSG_TYPE_VIDEO) {
$this->msgType = 'mpvideo';
}

Expand All @@ -167,7 +166,7 @@ public function build()
*/
public function buildPreview($by)
{
if (!in_array($by, $this->previewBys)) {
if (!in_array($by, $this->previewBys, true)) {
throw new InvalidArgumentException('This preview by not exist.');
}

Expand Down
9 changes: 4 additions & 5 deletions src/Broadcast/Transformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* @link https://github.com/overtrue
* @link http://overtrue.me
*/

namespace EasyWeChat\Broadcast;

use EasyWeChat\Core\Exceptions\InvalidArgumentException;
Expand Down Expand Up @@ -62,7 +61,7 @@ public function __construct($msgType, $message)
*/
public function transform()
{
$handle = sprintf("transform%s", ucfirst($this->msgType));
$handle = sprintf('transform%s', ucfirst($this->msgType));

return method_exists($this, $handle) ? $this->$handle($this->message) : [];
}
Expand Down Expand Up @@ -129,13 +128,13 @@ public function transformImage($message)
*/
public function transformVideo(array $message)
{
if (3 != count($message)) {
if (3 !== count($message)) {
throw new InvalidArgumentException('send message to openids, the message must be three arguments.');
}

return [
'video' => [
'media_id' => $message[0],
'media_id' => $message[0],
'title' => $message[1],
'description' => $message[2],
],
Expand All @@ -154,7 +153,7 @@ public function transformMpvideo($message)
{
return [
'mpvideo' => [
'media_id' => $message,
'media_id' => $message,
],
'msgtype' => 'mpvideo',
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace EasyWeChat\Foundation\ServiceProviders;

use EasyWeChat\Broadcast\Broadcast;
Expand Down
2 changes: 1 addition & 1 deletion tests/Broadcast/BroadcastBroadcastTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function getBroadcast()
$broadcast = Mockery::mock('EasyWeChat\Broadcast\Broadcast[parseJSON]', [Mockery::mock('EasyWeChat\Core\AccessToken')]);
$broadcast->shouldReceive('parseJSON')->andReturnUsing(function ($method, $params) {
return [
'api' => $params[0],
'api' => $params[0],
'params' => empty($params[1]) ? null : $params[1],
'quires' => empty($params[3]) ? null : $params[3],
];
Expand Down
4 changes: 2 additions & 2 deletions tests/Broadcast/BroadcastMessageBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
* with this source code in the file LICENSE.
*/

use EasyWeChat\Broadcast\MessageBuilder;
use EasyWeChat\Broadcast\Broadcast;
use EasyWeChat\Broadcast\MessageBuilder;

class BroadcastMessageBuilderTest extends PHPUnit_Framework_TestCase
{
Expand All @@ -33,7 +33,7 @@ public function testMsgType()
}

/**
* Test message();
* Test message();.
*/
public function testMessage()
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Broadcast/BroadcastTransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function testTransformVideo()

$msg = [
'video' => [
'media_id' => 'MEDIA_ID',
'media_id' => 'MEDIA_ID',
'title' => 'TITLE',
'description' => 'DESCRIPTION',
],
Expand All @@ -107,7 +107,7 @@ public function testTransformMpvideo()

$msg = [
'mpvideo' => [
'media_id' => 'MEDIA_ID',
'media_id' => 'MEDIA_ID',
],
'msgtype' => 'mpvideo',
];
Expand Down