Completed
Push — master ( 158640...6228b6 )
by Carlos
02:38 queued 01:15
created

Client   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A download() 0 15 2
1
<?php
2
3
/*
4
 * This file is part of the overtrue/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 EasyWeChat\Payment\Bill;
13
14
use EasyWeChat\Kernel\Http\StreamResponse;
15
use EasyWeChat\Payment\Kernel\BaseClient;
16
17
class Client extends BaseClient
18
{
19
    /**
20
     * Download bill history as a table file.
21
     *
22
     * @param string $date
23
     * @param string $type
24
     *
25
     * @return \EasyWeChat\Kernel\Http\StreamResponse|\Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
26
     */
27
    public function download(string $date, string $type = 'ALL')
28
    {
29
        $params = [
30
            'bill_date' => $date,
31
            'bill_type' => $type,
32
        ];
33
34
        $response = $this->requestRaw('pay/downloadbill', $params);
35
36
        if (strpos($response->getBody()->getContents(), '<xml>') === 0) {
37
            return $this->resolveResponse($response, $this->app['config']->get('response_type', 'array'));
38
        }
39
40
        return StreamResponse::buildFromPsrResponse($response);
41
    }
42
}
43