Completed
Pull Request — master (#1565)
by milkmeowo
03:58
created

ExternalContact   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 16
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __get() 0 7 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\Work\ExternalContact;
13
14
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
15
16
/**
17
 * Class ExternalContact.
18
 *
19
 * @author milkmeowo <[email protected]>
20
 *
21
 * @property \EasyWeChat\Work\ExternalContact\ContactWayClient $contact_way
22
 * @property \EasyWeChat\Work\ExternalContact\DataCubeClient $data_cube
23
 * @property \EasyWeChat\Work\ExternalContact\DimissionClient $dimission
24
 * @property \EasyWeChat\Work\ExternalContact\MessageClient $msg
25
 */
26
class ExternalContact extends Client
27
{
28
    /**
29
     * @param string $property
30
     *
31
     * @return mixed
32
     *
33
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
34
     */
35 1
    public function __get($property)
36
    {
37 1
        if (isset($this->app["external_contact.{$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 1
            return $this->app["external_contact.{$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 1
        throw new InvalidArgumentException(sprintf('No external_contact service named "%s".', $property));
42
    }
43
}
44