Skip to content

Commit

Permalink
change comment word (#830)
Browse files Browse the repository at this point in the history
CS.
  • Loading branch information
tianyong90 authored and overtrue committed Aug 1, 2017
1 parent b464c2c commit cba807d
Show file tree
Hide file tree
Showing 28 changed files with 657 additions and 350 deletions.
25 changes: 25 additions & 0 deletions src/Kernel/Contracts/MediaInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/*
* This file is part of the overtrue/wechat.
*
* (c) overtrue <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace EasyWeChat\Kernel\Contracts;

/**
* Interface MediaInterface.
*
* @author overtrue <[email protected]>
*/
interface MediaInterface extends MessageInterface
{
/**
* @return string
*/
public function getMediaId(): string;
}
35 changes: 35 additions & 0 deletions src/Kernel/Contracts/MessageInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/*
* This file is part of the overtrue/wechat.
*
* (c) overtrue <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace EasyWeChat\Kernel\Contracts;

/**
* Interface MessageInterface.
*
* @author overtrue <[email protected]>
*/
interface MessageInterface
{
/**
* @return string
*/
public function getType(): string;

/**
* @return mixed
*/
public function transformForJsonRequest(): array;

/**
* @return string
*/
public function transformToXml(): string;
}
22 changes: 19 additions & 3 deletions src/Kernel/Messages/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
*/
class Article extends Message
{
/**
* @var string
*/
protected $type = 'mpnews';

/**
* Properties.
*
Expand All @@ -36,8 +41,19 @@ class Article extends Message
*
* @var array
*/
protected $aliases = [
'source_url' => 'content_source_url',
'show_cover' => 'show_cover_pic',
protected $jsonAlias = [
'content_source_url' => 'source_url',
'show_cover_pic' => 'show_cover',
];

/**
* @var array
*/
protected $requirements = [
'thumb_media_id',
'title',
'content',
'source_url',
'show_cover',
];
}
6 changes: 3 additions & 3 deletions src/Kernel/Messages/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ class Card extends Message
protected $properties = ['card_id'];

/**
* Material constructor.
* Media constructor.
*
* @param string $cardId
*/
public function __construct($cardId)
public function __construct(string $cardId)
{
$this->set('card_id', $cardId);
parent::__construct(['card_id' => $cardId]);
}
}
36 changes: 36 additions & 0 deletions src/Kernel/Messages/Factory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/*
* This file is part of the overtrue/wechat.
*
* (c) overtrue <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace EasyWeChat\Kernel\Messages;

/**
* Class Factory.
*
* @author overtrue <[email protected]>
*/
class Factory
{
/**
* @param array $attributes
*/
public static function createFromMedia($attributes = [])
{
//TODO: 从素材转换为消息对象
}

/**
* @param array $attributes
*/
public static function createFromUserMessage($attributes = [])
{
//TODO: 从请求消息解析为消息对象
}
}
16 changes: 1 addition & 15 deletions src/Kernel/Messages/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* @property string $media_id
*/
class File extends Message
class File extends Media
{
/**
* Messages type.
Expand All @@ -33,18 +33,4 @@ class File extends Message
protected $properties = [
'media_id',
];

/**
* Set media_id.
*
* @param string $mediaId
*
* @return \EasyWeChat\Kernel\Messages\File
*/
public function file($mediaId)
{
$this->setAttribute('media_id', $mediaId);

return $this;
}
}
16 changes: 1 addition & 15 deletions src/Kernel/Messages/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* @property string $media_id
*/
class Image extends Message
class Image extends Media
{
/**
* Messages type.
Expand All @@ -31,18 +31,4 @@ class Image extends Message
* @var array
*/
protected $properties = ['media_id'];

/**
* Set media_id.
*
* @param string $mediaId
*
* @return Image
*/
public function media($mediaId)
{
$this->setAttribute('media_id', $mediaId);

return $this;
}
}
37 changes: 0 additions & 37 deletions src/Kernel/Messages/Material.php

This file was deleted.

58 changes: 58 additions & 0 deletions src/Kernel/Messages/Media.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/*
* This file is part of the overtrue/wechat.
*
* (c) overtrue <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace EasyWeChat\Kernel\Messages;

use EasyWeChat\Kernel\Contracts\MediaInterface;

/**
* Class Media.
*/
class Media extends Message implements MediaInterface
{
/**
* Properties.
*
* @var array
*/
protected $properties = ['media_id'];

/**
* @var array
*/
protected $requirements = [
'media_id',
];

/**
* MaterialClient constructor.
*
* @param string $type
* @param string $mediaId
* @param array $attributes
*/
public function __construct(string $type, string $mediaId, array $attributes = [])
{
parent::__construct(array_merge(['media_id' => $mediaId], $attributes));

$this->setType($type);
}

/**
* @return string
*/
public function getMediaId(): string
{
$this->checkRequiredAttributes();

return $this->get('media_id');
}
}
Loading

0 comments on commit cba807d

Please sign in to comment.