Skip to content

Commit

Permalink
Merge branch 'master' of github.com:overtrue/wechat
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Oct 11, 2019
2 parents a628fe2 + 0c65cac commit d04f571
Show file tree
Hide file tree
Showing 136 changed files with 1,846 additions and 148 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Expand Up @@ -6,7 +6,7 @@
.gitattributes export-ignore
.gitignore export-ignore
.scrutinizer.yml export-ignore
.travis.yml export-ignore
phpstan.neon export-ignore
phpunit.php export-ignore
phpunit.xml export-ignore
phpunit.xml.dist export-ignore
Expand Down
29 changes: 11 additions & 18 deletions .github/workflows/test.yml
Expand Up @@ -3,31 +3,24 @@ on: [push, pull_request]

jobs:
phpunit:
name: PHPUnit with PHP ${{ matrix.php_version }}
name: PHP-${{ matrix.php_version }}-${{ matrix.perfer }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php_version: ['7.1', '7.2', '7.3']
php_version:
- 7.1
- 7.2
- 7.3
- 7.4-rc
perfer:
- stable
- lowest
container:
image: php:${{ matrix.php_version }}-cli
image: nauxliu/php-ci-image:${{ matrix.php_version }}
steps:
- uses: actions/checkout@master
- name: Install Dependencies
run: |
apt-get update
apt-get install -y git unzip
# Instal composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php --install-dir=/usr/local/bin --filename composer
php -r "unlink('composer-setup.php');"
# copy default php.ini
cp /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini
# Install deps
composer install --no-progress --prefer-dist
run: composer update --prefer-dist --no-interaction --no-suggest --prefer-${{ matrix.perfer }}
- name: Run PHPUnit
run: ./vendor/bin/phpunit
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -4,15 +4,15 @@

📦 It is probably the best SDK in the world for developing Wechat App.

[![Build Status](https://wdp9fww0r9.execute-api.us-west-2.amazonaws.com/production/badge/overtrue/wechat)](https://wdp9fww0r9.execute-api.us-west-2.amazonaws.com/production/results/overtrue/wechat)
[![Test Status](https://github.com/overtrue/wechat/workflows/Test/badge.svg)](https://github.com/overtrue/wechat/actions)
[![Lint Status](https://github.com/overtrue/wechat/workflows/Lint/badge.svg)](https://github.com/overtrue/wechat/actions)
[![Latest Stable Version](https://poser.pugx.org/overtrue/wechat/v/stable.svg)](https://packagist.org/packages/overtrue/wechat)
[![Latest Unstable Version](https://poser.pugx.org/overtrue/wechat/v/unstable.svg)](https://packagist.org/packages/overtrue/wechat)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/overtrue/wechat/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/overtrue/wechat/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/overtrue/wechat/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/overtrue/wechat/?branch=master)
[![Total Downloads](https://poser.pugx.org/overtrue/wechat/downloads)](https://packagist.org/packages/overtrue/wechat)
[![License](https://poser.pugx.org/overtrue/wechat/license)](https://packagist.org/packages/overtrue/wechat)

[![7.0-9.9](https://raw.githubusercontent.com/ruffood/ruofan/master/img/ad0724.jpg)](http://prt.ruffood.com/jump/overtrue)

## Requirement

Expand All @@ -24,7 +24,7 @@
## Installation

```shell
$ composer require "overtrue/wechat:~4.1" -vvv
$ composer require "overtrue/wechat:^4.2" -vvv
```

## Usage
Expand Down
19 changes: 8 additions & 11 deletions composer.json
Expand Up @@ -21,24 +21,21 @@
"ext-simplexml": "*",
"easywechat-composer/easywechat-composer": "^1.1",
"guzzlehttp/guzzle": "^6.2",
"monolog/monolog": "^1.22",
"monolog/monolog": "^1.22 || ^2.0",
"overtrue/socialite": "~2.0",
"pimple/pimple": "^3.0",
"psr/simple-cache": "^1.0",
"symfony/cache": "^3.3 || ^4.3",
"symfony/event-dispatcher": "^4.3",
"symfony/http-foundation": "^2.7 || ^3.0 || ^4.0",
"symfony/psr-http-message-bridge": "^0.3 || ^1.0"
},
"require-dev": {
"mikey179/vfsStream": "^1.6",
"mockery/mockery": "^1.0",
"phpunit/phpunit": "~6.5",
"symfony/event-dispatcher": "^4.0",
"friendsofphp/php-cs-fixer": "^2.15",
"mikey179/vfsstream": "^1.6",
"mockery/mockery": "^1.2.3",
"phpstan/phpstan": "^0.11.12",
"friendsofphp/php-cs-fixer": "^2.15"
},
"suggest": {
"symfony/event-dispatcher": "Required to use EasyWeChat events component (^4.0)."
"phpunit/phpunit": "^7.5"
},
"autoload": {
"psr-4": {
Expand All @@ -55,8 +52,8 @@
}
},
"scripts": {
"test": "vendor/bin/phpunit",
"phpcs": "vendor/bin/php-cs-fixer fix",
"phpstan": "vendor/bin/phpstan analyse"
"phpstan": "vendor/bin/phpstan analyse",
"test": "vendor/bin/phpunit"
}
}
3 changes: 1 addition & 2 deletions phpunit.xml
Expand Up @@ -7,8 +7,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
stopOnFailure="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
Expand Down
64 changes: 64 additions & 0 deletions src/BasicService/ContentSecurity/Client.php
Expand Up @@ -12,6 +12,7 @@
namespace EasyWeChat\BasicService\ContentSecurity;

use EasyWeChat\Kernel\BaseClient;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;

/**
* Class Client.
Expand All @@ -33,6 +34,7 @@ class Client extends BaseClient
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function checkText(string $text)
{
Expand All @@ -51,9 +53,71 @@ public function checkText(string $text)
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function checkImage(string $path)
{
return $this->httpUpload('img_sec_check', ['media' => $path]);
}

/**
* Media security check.
*
* @param string $mediaUrl
* @param int $mediaType
*
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
*/
public function checkMediaAsync(string $mediaUrl, int $mediaType)
{
/*
* 1:音频;2:图片
*/
$mediaTypes = [1, 2];

if (!in_array($mediaType, $mediaTypes, true)) {
throw new InvalidArgumentException('media type must be 1 or 2');
}

$params = [
'media_url' => $mediaUrl,
'media_type' => $mediaType,
];

return $this->httpPostJson('media_check_async', $params);
}

/**
* Image security check async.
*
* @param string $mediaUrl
*
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function checkImageAsync(string $mediaUrl)
{
return $this->checkMediaAsync($mediaUrl, 2);
}

/**
* Audio security check async.
*
* @param string $mediaUrl
*
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function checkAudioAsync(string $mediaUrl)
{
return $this->checkMediaAsync($mediaUrl, 1);
}
}
8 changes: 5 additions & 3 deletions src/BasicService/Jssdk/Client.php
Expand Up @@ -84,10 +84,11 @@ public function getConfigArray(array $apis, bool $debug = false, bool $beta = fa
*
* @return array
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \Psr\SimpleCache\InvalidArgumentException
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function getTicket(bool $refresh = false, string $type = 'jsapi'): array
{
Expand Down Expand Up @@ -121,9 +122,10 @@ public function getTicket(bool $refresh = false, string $type = 'jsapi'): array
*
* @return array
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \Psr\SimpleCache\InvalidArgumentException
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
protected function configSignature(string $url = null, string $nonce = null, $timestamp = null): array
{
Expand Down
3 changes: 3 additions & 0 deletions src/BasicService/QrCode/Client.php
Expand Up @@ -98,6 +98,9 @@ public function url($ticket)
* @param int $expireSeconds
*
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
protected function create($actionName, $actionInfo, $temporary = true, $expireSeconds = null)
{
Expand Down
3 changes: 3 additions & 0 deletions src/BasicService/Url/Client.php
Expand Up @@ -31,6 +31,9 @@ class Client extends BaseClient
* @param string $url
*
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function shorten(string $url)
{
Expand Down
4 changes: 3 additions & 1 deletion src/Kernel/AccessToken.php
Expand Up @@ -130,8 +130,9 @@ public function getToken(bool $refresh = false): array
*
* @return \EasyWeChat\Kernel\Contracts\AccessTokenInterface
*
* @throws \Psr\SimpleCache\InvalidArgumentException
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function setToken(string $token, int $lifetime = 7200): AccessTokenInterface
{
Expand Down Expand Up @@ -215,6 +216,7 @@ public function applyToRequest(RequestInterface $request, array $requestOptions
* @return ResponseInterface
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
protected function sendRequest(array $credentials): ResponseInterface
{
Expand Down
2 changes: 2 additions & 0 deletions src/Kernel/BaseClient.php
Expand Up @@ -65,6 +65,7 @@ public function __construct(ServiceContainer $app, AccessTokenInterface $accessT
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function httpGet(string $url, array $query = [])
{
Expand All @@ -80,6 +81,7 @@ public function httpGet(string $url, array $query = [])
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function httpPost(string $url, array $data = [])
{
Expand Down
72 changes: 0 additions & 72 deletions src/Kernel/EventDispatcher/Dispatcher.php

This file was deleted.

0 comments on commit d04f571

Please sign in to comment.