Completed
Pull Request — master (#1564)
by milkmeowo
07:34 queued 01:26
created

Crm::__get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
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\Work\Crm;
13
14
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
15
16
/**
17
 * Class Crm.
18
 *
19
 * @author milkmeowo <[email protected]>
20
 *
21
 * @property \EasyWeChat\Work\Crm\ContactWayClient $contact_way
22
 * @property \EasyWeChat\Work\Crm\DataCubeClient $data_cube
23
 * @property \EasyWeChat\Work\Crm\DimissionClient $dimission
24
 * @property \EasyWeChat\Work\Crm\MessageClient $msg
25
 */
26
class Crm extends Client
27
{
28
    /**
29
     * @param string $property
30
     *
31
     * @return mixed
32
     *
33
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
34
     */
35
    public function __get($property)
36
    {
37
        if (isset($this->app["crm.{$property}"])) {
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $property instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
38
            return $this->app["crm.{$property}"];
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $property instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
39
        }
40
41
        throw new InvalidArgumentException(sprintf('No crm service named "%s".', $property));
42
    }
43
}
44