<commit_before><?php
/**
 * Created by PhpStorm.
 * User: helei
 * Date: 2017/4/29
 * Time: 上午10:36
 */

namespace Payment\Notify;


use Payment\Common\CmbConfig;
use Payment\Common\PayException;
use Payment\Config;
use Payment\Utils\ArrayUtil;
use Payment\Utils\RsaEncrypt;

/**
 * 招商回调处理
 * Class CmbNotify
 * @package Payment\Notify
 */
class CmbNotify extends NotifyStrategy
{

    /**
     * CmbNotify constructor.
     * @param array $config
     * @throws PayException
     */
    public function __construct(array $config)
    {
        parent::__construct($config);

        try {
            $this->config = new CmbConfig($config);
        } catch (PayException $e) {
            throw $e;
        }
    }

    public function getNotifyData()
    {
        $data = empty($_POST) ? $_GET : $_POST;
        if (empty($data) || ! is_array($data)) {
            return false;
        }

        $retData = json_decode(urldecode($data[CmbConfig::REQ_FILED_NAME]), true);
        return $retData;
    }

    /**
     * 对返回信息验证签名
     * @param array $data
     * @return boolean
     */
    public function checkNotifyData(array $data)
    {
        $signType = strtoupper($data['signType']);
        $sign = $data['sign'];

        // 1. 对待签名参数数组排序
        $values = ArrayUtil::arraySort($data['noticeData']);
        // 2. 将排序后的参数与其对应值，组合成“参数=参数值”的格式,用&字符连接起来
        $preStr = ArrayUtil::createLinkstring($values);

        if ($signType === 'RSA') {// 使用rsa方式
            $rsa = new RsaEncrypt($this->config->rsaPubKey);

            return $rsa->rsaVerify($preStr, $sign);
        } else {
            return false;
        }<commit_msg>pr提交错误，修复问题<commit_after><?php
/**
 * Created by PhpStorm.
 * User: helei
 * Date: 2017/4/29
 * Time: 上午10:36
 */

namespace Payment\Notify;


use Payment\Common\CmbConfig;
use Payment\Common\PayException;
use Payment\Config;
use Payment\Utils\ArrayUtil;
use Payment\Utils\RsaEncrypt;

/**
 * 招商回调处理
 * Class CmbNotify
 * @package Payment\Notify
 */
class CmbNotify extends NotifyStrategy
{

    /**
     * CmbNotify constructor.
     * @param array $config
     * @throws PayException
     */
    public function __construct(array $config)
    {
        parent::__construct($config);

        try {
            $this->config = new CmbConfig($config);
        } catch (PayException $e) {
            throw $e;
        }
    }

    public function getNotifyData()
    {
        $data = empty($_POST) ? $_GET : $_POST;
        if (empty($data) || ! is_array($data)) {
            return false;
        }

        $retData = json_decode($data[CmbConfig::REQ_FILED_NAME], true);
        return $retData;
    }

    /**
     * 对返回信息验证签名
     * @param array $data
     * @return boolean
     */
    public function checkNotifyData(array $data)
    {
        $signType = strtoupper($data['signType']);
        $sign = $data['sign'];

        // 1. 对待签名参数数组排序
        $values = ArrayUtil::arraySort($data['noticeData']);
        // 2. 将排序后的参数与其对应值，组合成“参数=参数值”的格式,用&字符连接起来
        $preStr = ArrayUtil::createLinkstring($values);

        if ($signType === 'RSA') {// 使用rsa方式
            $rsa = new RsaEncrypt($this->config->rsaPubKey);

            return $rsa->rsaVerify($preStr, $sign);
        } else {
            return false;
        }
{'fraction_non_alphanumeric': 0.14006713457430578, 'fraction_numerical': 0.007934086054317974, 'mean_word_length': 2.2295566502463053, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4005153', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1150, 'n_words': 208}