for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the overtrue/wechat.
*
* (c) overtrue <[email protected]>
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace EasyWeChat\Work\ExternalContact;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
/**
* Class ExternalContact.
* @author milkmeowo <[email protected]>
* @property \EasyWeChat\Work\ExternalContact\ContactWayClient $contact_way
* @property \EasyWeChat\Work\ExternalContact\DataCubeClient $data_cube
* @property \EasyWeChat\Work\ExternalContact\DimissionClient $dimission
* @property \EasyWeChat\Work\ExternalContact\MessageClient $msg
class ExternalContact extends Client
{
* @param string $property
* @return mixed
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
public function __get($property)
if (isset($this->app["external_contact.{$property}"])) {
sprintf
$property
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);
return $this->app["external_contact.{$property}"];
}
throw new InvalidArgumentException(sprintf('No external_contact service named "%s".', $property));
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.