Completed
Push — master ( a679b5...bc4430 )
by Carlos
03:34
created

Card::deposit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 2
dl 9
loc 9
ccs 5
cts 5
cp 1
crap 1
rs 9.6666
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
/**
13
 * Card.php.
14
 *
15
 * @author    overtrue <[email protected]>
16
 * @copyright 2016 overtrue <[email protected]>
17
 *
18
 * @link      https://github.com/overtrue
19
 * @link      http://overtrue.me
20
 */
21
namespace EasyWeChat\Card;
22
23
use Doctrine\Common\Cache\Cache;
24
use Doctrine\Common\Cache\FilesystemCache;
25
use EasyWeChat\Core\AbstractAPI;
26
use Psr\Http\Message\ResponseInterface;
27
28
class Card extends AbstractAPI
29
{
30
    /**
31
     * Cache.
32
     *
33
     * @var Cache
34
     */
35
    protected $cache;
36
37
    /**
38
     * Ticket cache prefix.
39
     */
40
    const TICKET_CACHE_PREFIX = 'overtrue.wechat.card_api_ticket.';
41
42
    const API_GET_COLORS = 'https://api.weixin.qq.com/card/getcolors';
43
    const API_CREATE = 'https://api.weixin.qq.com/card/create';
44
    const API_QRCODE_CREATE = 'https://api.weixin.qq.com/card/qrcode/create';
45
    const API_QRCODE_SHOW = 'https://mp.weixin.qq.com/cgi-bin/showqrcode';
46
    const API_GET_CARD_TICKET = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket';
47
    const API_LANDING_PAGE = 'https://api.weixin.qq.com/card/landingpage/create';
48
    const API_DEPOSIT = 'https://api.weixin.qq.com/card/code/deposit';
49
    const API_GET_DEPOSIT_COUNT = 'https://api.weixin.qq.com/card/code/getdepositcount';
50
    const API_CHECK_CODE = 'https://api.weixin.qq.com/card/code/checkcode';
51
    const API_GET_HTML = 'https://api.weixin.qq.com/card/mpnews/gethtml';
52
    const API_TEST_WHITE_LIST = 'https://api.weixin.qq.com/card/testwhitelist/set';
53
    const API_CODE_GET = 'https://api.weixin.qq.com/card/code/get';
54
    const API_CONSUME = 'https://api.weixin.qq.com/card/code/consume';
55
    const API_DECRYPT = 'https://api.weixin.qq.com/card/code/decrypt';
56
    const API_GET_CARD_LIST = 'https://api.weixin.qq.com/card/user/getcardlist';
57
    const API_CARD_GET = 'https://api.weixin.qq.com/card/get';
58
    const API_BATCH_GET = 'https://api.weixin.qq.com/card/batchget';
59
    const API_UPDATE = 'https://api.weixin.qq.com/card/update';
60
    const API_PAY_CELL_SET = 'https://api.weixin.qq.com/card/paycell/set';
61
    const API_MODIFY_STOCK = 'https://api.weixin.qq.com/card/modifystock';
62
    const API_CODE_UPDATE = 'https://api.weixin.qq.com/card/code/update';
63
    const API_CARD_DELETE = 'https://api.weixin.qq.com/card/delete';
64
    const API_UNAVAILABLE = 'https://api.weixin.qq.com/card/code/unavailable';
65
    const API_CARD_BIZ_UIN_INFO = 'https://api.weixin.qq.com/datacube/getcardbizuininfo';
66
    const API_CARD_CARD_INFO = 'https://api.weixin.qq.com/datacube/getcardcardinfo';
67
    const API_CARD_MEMBER_CARD_INFO = 'https://api.weixin.qq.com/datacube/getcardmembercardinfo';
68
    const API_CARD_ACTIVATE = 'https://api.weixin.qq.com/card/membercard/activate';
69
    const API_ACTIVATE_USER_FORM = 'https://api.weixin.qq.com/card/membercard/activateuserform/set';
70
    const API_MEMBER_USER_INFO = 'https://api.weixin.qq.com/card/membercard/userinfo/get';
71
    const API_UPDATE_USER = 'https://api.weixin.qq.com/card/membercard/updateuser';
72
    const API_SUB_MERCHANT = 'https://api.weixin.qq.com/card/submerchant/submit';
73
    const API_GET_APPLY_PROTOCOL = 'https://api.weixin.qq.com/card/getapplyprotocol';
74
75
    /**
76
     * 获取卡券颜色.
77
     *
78
     * @return array
79
     */
80 1
    public function getColors()
81
    {
82 1
        return $this->parseJSON('get', [self::API_GET_COLORS]);
83
    }
84
85
    /**
86
     * 创建卡券.
87
     *
88
     * @param string $cardType
89
     * @param array  $baseInfo
90
     * @param array  $especial
91
     * @param array  $advancedInfo
92
     *
93
     * @return bool|array
94
     */
95 1
    public function create($cardType = 'member_card', $baseInfo = [], $especial = [], $advancedInfo = [])
96
    {
97 1
        $card = [];
98 1
        $card['card'] = [];
99 1
        $card['card']['card_type'] = strtoupper($cardType);
100
101 1
        $type = strtolower($cardType);
102
103
        $cardInfo = [
104 1
            'base_info' => $baseInfo,
105 1
        ];
106
107 1
        $card['card'][$type] = [];
108 1
        $card['card'][$type] = array_merge($cardInfo, $especial, $advancedInfo);
109
110 1
        if (is_string($cardType) && is_array($baseInfo) && is_array($especial)) {
111 1
            return $this->parseJSON('json', [self::API_CREATE, $card]);
112
        }
113
114
        return false;
115
    }
116
117
    /**
118
     * 创建二维码.
119
     *
120
     * @param array $cards
121
     *
122
     * @return array|bool
123
     */
124 1
    public function QRCode($cards = [])
125
    {
126 1
        return $this->parseJSON('json', [self::API_QRCODE_CREATE, $cards]);
127
    }
128
129
    /**
130
     * ticket 换取二维码图片.
131
     *
132
     * @param string $ticket
133
     *
134
     * @return array
135
     */
136 1
    public function showQRCode($ticket = null)
137
    {
138
        $params = [
139 1
            'ticket' => $ticket,
140 1
        ];
141
142 1
        $http = $this->getHttp();
143
144
        /** @var ResponseInterface $response */
145 1
        $response = $http->get(self::API_QRCODE_SHOW, $params);
146
147
        return [
148 1
            'status' => $response->getStatusCode(),
149 1
            'reason' => $response->getReasonPhrase(),
150 1
            'headers' => $response->getHeaders(),
151 1
            'body' => strval($response->getBody()),
152 1
            'url' => self::API_QRCODE_SHOW.'?'.http_build_query($params),
153 1
        ];
154
    }
155
156
    /**
157
     * 通过ticket换取二维码 链接.
158
     *
159
     * @param string $ticket
160
     *
161
     * @return string
162
     */
163 1
    public function getQRCodeUrl($ticket)
164
    {
165 1
        $params = '?ticket='.$ticket;
166
167 1
        return self::API_QRCODE_SHOW.$params;
168
    }
169
170
    /**
171
     * 获取 卡券 Api_ticket.
172
     *
173
     * @param bool $refresh 是否强制刷新
174
     *
175
     * @return string $apiTicket
176
     */
177 2 View Code Duplication
    public function getAPITicket($refresh = false)
178
    {
179 2
        $key = self::TICKET_CACHE_PREFIX.$this->getAccessToken()->getAppId();
180
181 2
        $ticket = $this->getCache()->fetch($key);
182
183 2
        if (!$ticket || $refresh) {
184 1
            $result = $this->parseJSON('get', [self::API_GET_CARD_TICKET, ['type' => 'wx_card']]);
185
186 1
            $this->getCache()->save($key, $result['ticket'], $result['expires_in'] - 500);
187
188 1
            return $result['ticket'];
189
        }
190
191 1
        return $ticket;
192
    }
193
194
    /**
195
     * 微信卡券:JSAPI 卡券Package - 基础参数没有附带任何值 - 再生产环境中需要根据实际情况进行修改.
196
     *
197
     * @param array  $cards
198
     * @param int    $timestamp
199
     * @param string $apiTicket
200
     *
201
     * @return string
202
     */
203 1
    public function wxCardPackage(array $cards, $timestamp = null, $apiTicket = null)
204
    {
205 1
        if (empty($timestamp) || $timestamp === '') {
0 ignored issues
show
Unused Code Bug introduced by
The strict comparison === seems to always evaluate to false as the types of $timestamp (integer) and '' (string) can never be identical. Maybe you want to use a loose comparison == instead?
Loading history...
206 1
            $timestamp = time();
207 1
        }
208
209 1
        if (empty($apiTicket) || $apiTicket === '') {
210 1
            $apiTicket = $this->getAPITicket();
211 1
        }
212
213 1
        $result = [];
214 1
        foreach ($cards as $index => $card) {
215 1 View Code Duplication
            if (empty($card['code']) || !isset($card['code'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
216 1
                $card['code'] = '';
217 1
            }
218
219 1 View Code Duplication
            if (empty($card['openid']) || !isset($card['openid'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
220 1
                $card['openid'] = '';
221 1
            }
222
223 1
            $arrays = [$apiTicket, $timestamp, $card['card_id'], $card['code'], $card['openid']];
224 1
            sort($arrays, SORT_STRING);
225 1
            $string = sha1(implode($arrays));
226
227 1
            $result['cardList'][$index]['cardId'] = $card['card_id'];
228 1
            $result['cardList'][$index]['cardExt']['code'] = $card['code'];
229 1
            $result['cardList'][$index]['cardExt']['openid'] = $card['openid'];
230
231 1
            $result['cardList'][$index]['cardExt']['timestamp'] = $timestamp;
232 1
            $result['cardList'][$index]['cardExt']['signature'] = $string;
233
234 1
            if (!empty($card['outer_id'])) {
235 1
                $result['cardList'][$index]['cardExt']['outer_id'] = $card['outer_id'];
236 1
            }
237
238 1
            $result['cardList'][$index]['cardExt'] = json_encode($result['cardList'][$index]['cardExt']);
239 1
        }
240
241 1
        return json_encode($result);
242
    }
243
244
    /**
245
     * 创建货架接口.
246
     *
247
     * @param string $banner
248
     * @param string $pageTitle
249
     * @param bool   $canShare
250
     * @param string $scene     [SCENE_NEAR_BY 附近,SCENE_MENU 自定义菜单,SCENE_QRCODE 二维码,SCENE_ARTICLE 公众号文章,
251
     *                          SCENE_H5 h5页面,SCENE_IVR 自动回复,SCENE_CARD_CUSTOM_CELL 卡券自定义cell]
252
     * @param array  $cardList
253
     *
254
     * @return array
255
     */
256 1
    public function createLandingPage($banner, $pageTitle, $canShare, $scene, $cardList)
257
    {
258
        $params = [
259 1
            'banner' => $banner,
260 1
            'page_title' => $pageTitle,
261 1
            'can_share' => $canShare,
262 1
            'scene' => $scene,
263 1
            'card_list' => $cardList,
264 1
        ];
265
266 1
        return $this->parseJSON('json', [self::API_LANDING_PAGE, $params]);
267
    }
268
269
    /**
270
     * 导入code接口.
271
     *
272
     * @param string $cardId
273
     * @param array  $code
274
     *
275
     * @return array
276
     */
277 1 View Code Duplication
    public function deposit($cardId, $code)
278
    {
279
        $params = [
280 1
            'card_id' => $cardId,
281 1
            'code' => $code,
282 1
        ];
283
284 1
        return $this->parseJSON('json', [self::API_DEPOSIT, $params]);
285
    }
286
287
    /**
288
     * 查询导入code数目.
289
     *
290
     * @param string $cardId
291
     *
292
     * @return array
293
     */
294 1 View Code Duplication
    public function getDepositedCount($cardId)
295
    {
296
        $params = [
297 1
            'card_id' => $cardId,
298 1
        ];
299
300 1
        return $this->parseJSON('json', [self::API_GET_DEPOSIT_COUNT, $params]);
301
    }
302
303
    /**
304
     * 核查code接口.
305
     *
306
     * @param string $cardId
307
     * @param array  $code
308
     *
309
     * @return array
310
     */
311 1 View Code Duplication
    public function checkCode($cardId, $code)
312
    {
313
        $params = [
314 1
            'card_id' => $cardId,
315 1
            'code' => $code,
316 1
        ];
317
318 1
        return $this->parseJSON('json', [self::API_CHECK_CODE, $params]);
319
    }
320
321
    /**
322
     * 图文消息群发卡券.
323
     *
324
     * @param string $cardId
325
     *
326
     * @return array
327
     */
328 1 View Code Duplication
    public function getHtml($cardId)
329
    {
330
        $params = [
331 1
            'card_id' => $cardId,
332 1
        ];
333
334 1
        return $this->parseJSON('json', [self::API_GET_HTML, $params]);
335
    }
336
337
    /**
338
     * 设置测试白名单.
339
     *
340
     * @param array $openid
341
     * @param array $username
342
     *
343
     * @return array
344
     */
345 1
    public function setTestWhitelist($openid, $username)
346
    {
347
        $params = [
348 1
            'openid' => $openid,
349 1
            'username' => $username,
350 1
        ];
351
352 1
        return $this->parseJSON('json', [self::API_TEST_WHITE_LIST, $params]);
353
    }
354
355
    /**
356
     * 查询Code接口.
357
     *
358
     * @param string $code
359
     * @param bool   $checkConsume
360
     * @param string $cardId
361
     *
362
     * @return array
363
     */
364 1 View Code Duplication
    public function getCode($code, $checkConsume, $cardId)
365
    {
366
        $params = [
367 1
            'code' => $code,
368 1
            'check_consume' => $checkConsume,
369 1
            'card_id' => $cardId,
370 1
        ];
371
372 1
        return $this->parseJSON('json', [self::API_CODE_GET, $params]);
373
    }
374
375
    /**
376
     * 核销Code接口.
377
     *
378
     * @param string $cardId
379
     * @param string $code
380
     *
381
     * @return array
382
     */
383 1 View Code Duplication
    public function consume($cardId, $code)
384
    {
385
        $params = [
386 1
            'card_id' => $cardId,
387 1
            'code' => $code,
388 1
        ];
389
390 1
        return $this->parseJSON('json', [self::API_CONSUME, $params]);
391
    }
392
393
    /**
394
     * Code解码接口.
395
     *
396
     * @param string $encryptedCode
397
     *
398
     * @return array
399
     */
400 1
    public function decryptCode($encryptedCode)
401
    {
402
        $params = [
403 1
            'encrypt_code' => $encryptedCode,
404 1
        ];
405
406 1
        return $this->parseJSON('json', [self::API_DECRYPT, $params]);
407
    }
408
409
    /**
410
     * 获取用户已领取卡券接口.
411
     *
412
     * @param string $openid
413
     * @param string $cardId
414
     *
415
     * @return array
416
     */
417 1 View Code Duplication
    public function getUserCards($openid, $cardId = '')
418
    {
419
        $params = [
420 1
            'openid' => $openid,
421 1
            'card_id' => $cardId,
422 1
        ];
423
424 1
        return $this->parseJSON('json', [self::API_GET_CARD_LIST, $params]);
425
    }
426
427
    /**
428
     * 查看卡券详情.
429
     *
430
     * @param string $cardId
431
     *
432
     * @return array
433
     */
434 1 View Code Duplication
    public function getCard($cardId)
435
    {
436
        $params = [
437 1
            'card_id' => $cardId,
438 1
        ];
439
440 1
        return $this->parseJSON('json', [self::API_CARD_GET, $params]);
441
    }
442
443
    /**
444
     * 批量查询卡列表.
445
     *
446
     * @param int    $offset
447
     * @param int    $count
448
     * @param string $statusList
449
     *
450
     * @return array
451
     */
452 1 View Code Duplication
    public function lists($offset = 0, $count = 10, $statusList = 'CARD_STATUS_VERIFY_OK')
453
    {
454
        $params = [
455 1
            'offset' => $offset,
456 1
            'count' => $count,
457 1
            'status_list' => $statusList,
458 1
        ];
459
460 1
        return $this->parseJSON('json', [self::API_BATCH_GET, $params]);
461
    }
462
463
    /**
464
     * 更改卡券信息接口 and 设置跟随推荐接口.
465
     *
466
     * @param string $cardId
467
     * @param string $type
468
     * @param array  $baseInfo
469
     * @param array  $especial
470
     *
471
     * @return array
472
     */
473 1
    public function update($cardId, $type, $baseInfo = [], $especial = [])
474
    {
475 1
        $card = [];
476 1
        $card['card_id'] = $cardId;
477 1
        $card[$type] = [];
478
479 1
        $cardInfo = [];
480 1
        $cardInfo['base_info'] = $baseInfo;
481
482 1
        $card[$type] = array_merge($cardInfo, $especial);
483
484 1
        return $this->parseJSON('json', [self::API_UPDATE, $card]);
485
    }
486
487
    /**
488
     * 设置微信买单接口.
489
     * 设置买单的card_id必须已经配置了门店,否则会报错.
490
     *
491
     * @param string $cardId
492
     * @param bool   $isOpen
493
     *
494
     * @return array
495
     */
496 1 View Code Duplication
    public function setPayCell($cardId, $isOpen = true)
497
    {
498
        $params = [
499 1
            'card_id' => $cardId,
500 1
            'is_open' => $isOpen,
501 1
        ];
502
503 1
        return $this->parseJSON('json', [self::API_PAY_CELL_SET, $params]);
504
    }
505
506
    /**
507
     * 修改库存接口.
508
     *
509
     * @param string $cardId
510
     * @param string $stock
511
     * @param int    $value
512
     *
513
     * @return array
514
     */
515 1
    public function modifyStock($cardId, $stock = 'increase', $value = 0)
516
    {
517
        $params = [
518 1
            'card_id' => $cardId,
519 1
        ];
520
521 1
        if ($stock === 'increase') {
522 1
            $params['increase_stock_value'] = intval($value);
523 1
        } elseif ($stock === 'reduce') {
524
            $params['reduce_stock_value'] = intval($value);
525
        } else {
526
            return false;
527
        }
528
529 1
        return $this->parseJSON('json', [self::API_MODIFY_STOCK, $params]);
530
    }
531
532
    /**
533
     * 更改Code接口.
534
     *
535
     * @param string $code
536
     * @param string $newCode
537
     * @param array  $cardId
538
     *
539
     * @return array
540
     */
541 1 View Code Duplication
    public function updateCode($code, $newCode, $cardId = [])
542
    {
543
        $params = [
544 1
            'code' => $code,
545 1
            'new_code' => $newCode,
546 1
            'card_id' => $cardId,
547 1
        ];
548
549 1
        return $this->parseJSON('json', [self::API_CODE_UPDATE, $params]);
550
    }
551
552
    /**
553
     * 删除卡券接口.
554
     *
555
     * @param string $cardId
556
     *
557
     * @return array
558
     */
559 1 View Code Duplication
    public function delete($cardId)
560
    {
561
        $params = [
562 1
            'card_id' => $cardId,
563 1
        ];
564
565 1
        return $this->parseJSON('json', [self::API_CARD_DELETE, $params]);
566
    }
567
568
    /**
569
     * 设置卡券失效.
570
     *
571
     * @param string $code
572
     * @param string $cardId
573
     *
574
     * @return array
575
     */
576 1 View Code Duplication
    public function disable($code, $cardId = '')
577
    {
578
        $params = [
579 1
            'code' => $code,
580 1
            'card_id' => $cardId,
581 1
        ];
582
583 1
        return $this->parseJSON('json', [self::API_UNAVAILABLE, $params]);
584
    }
585
586
    /**
587
     * 会员卡接口激活.
588
     *
589
     * @param array $activate
590
     *
591
     * @return array
592
     */
593 1
    public function activate($activate = [])
594
    {
595 1
        return $this->parseJSON('json', [self::API_CARD_ACTIVATE, $activate]);
596
    }
597
598
    /**
599
     * 设置开卡字段接口.
600
     *
601
     * @param string $cardId
602
     * @param array  $requiredForm
603
     * @param array  $optionalForm
604
     *
605
     * @return array
606
     */
607 1
    public function activateUserForm($cardId, $requiredForm = [], $optionalForm = [])
608
    {
609 1
        $card = [];
610 1
        $card['card_id'] = $cardId;
611
612 1
        $params = array_merge($card, $requiredForm, $optionalForm);
613
614 1
        return $this->parseJSON('json', [self::API_ACTIVATE_USER_FORM, $params]);
615
    }
616
617
    /**
618
     * 拉取会员信息接口.
619
     *
620
     * @param string $cardId
621
     * @param string $code
622
     *
623
     * @return array
624
     */
625 1 View Code Duplication
    public function getMemberCardUser($cardId, $code)
626
    {
627
        $params = [
628 1
            'card_id' => $cardId,
629 1
            'code' => $code,
630 1
        ];
631
632 1
        return $this->parseJSON('json', [self::API_MEMBER_USER_INFO, $params]);
633
    }
634
635
    /**
636
     * 更新会员信息.
637
     *
638
     * @param array $updateUser
639
     *
640
     * @return array
641
     */
642 1
    public function updateMemberCardUser($updateUser = [])
643
    {
644 1
        $params = $updateUser;
645
646 1
        return $this->parseJSON('json', [self::API_UPDATE_USER, $params]);
647
    }
648
649
    /**
650
     * 添加子商户.
651
     *
652
     * @param string $brandName
653
     * @param string $logoUrl
654
     * @param string $protocol
655
     * @param int    $endTime
656
     * @param int    $primaryCategoryId
657
     * @param int    $secondaryCategoryId
658
     * @param string $agreementMediaId
659
     * @param string $operatorMediaId
660
     * @param string $appId
661
     *
662
     * @return array
663
     */
664 1
    public function subMerchant($brandName, $logoUrl, $protocol, $endTime, $primaryCategoryId, $secondaryCategoryId, $agreementMediaId, $operatorMediaId, $appId = '')
665
    {
666
        $params = [
667
            'info' => [
668 1
                'brand_name' => $brandName,
669 1
                'logo_url' => $logoUrl,
670 1
                'protocol' => $protocol,
671 1
                'end_time' => $endTime,
672 1
                'primary_category_id' => $primaryCategoryId,
673 1
                'secondary_category_id' => $secondaryCategoryId,
674 1
                'agreement_media_id' => $agreementMediaId,
675 1
                'operator_media_id' => $operatorMediaId,
676 1
                'app_id' => $appId,
677 1
            ],
678 1
        ];
679
680 1
        return $this->parseJSON('json', [self::API_SUB_MERCHANT, $params]);
681
    }
682
683
    /**
684
     * 卡券开放类目查询接口.
685
     *
686
     * @return array|bool
687
     */
688 1
    public function getApplyProtocol()
689
    {
690 1
        return $this->parseJSON('get', [self::API_GET_APPLY_PROTOCOL]);
691
    }
692
693
    /**
694
     * Set cache manager.
695
     *
696
     * @param \Doctrine\Common\Cache\Cache $cache
697
     *
698
     * @return $this
699
     */
700 2
    public function setCache(Cache $cache)
701
    {
702 2
        $this->cache = $cache;
703
704 2
        return $this;
705
    }
706
707
    /**
708
     * Return cache manager.
709
     *
710
     * @return \Doctrine\Common\Cache\Cache
711
     */
712 2
    public function getCache()
713
    {
714 2
        return $this->cache ?: $this->cache = new FilesystemCache(sys_get_temp_dir());
715
    }
716
717
    /**
718
     * Set current url.
719
     *
720
     * @param string $url
721
     *
722
     * @return array
723
     */
724 1
    public function setUrl($url)
725
    {
726 1
        $this->url = $url;
0 ignored issues
show
Bug introduced by
The property url does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
727
728 1
        return $this;
729
    }
730
}
731