for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Pablumfication\LaravelSiftScience\Services;
class SiftScienceService
{
/**
* Get auth parameters from config, fail if any are missing.
* Instantiate API client and set auth token.
*
* @throws Exception
*/
public function __construct()
$this->api_key = config('laravel-sift-science.api_key');
api_key
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;
$this->account_id = config('laravel-sift-science.account_id');
account_id
$this->timeout = config('laravel-sift-science.timeout');
timeout
$this->version = config('laravel-sift-science.version');
version
if (!$this->api_key || !$this->account_id) {
throw new \InvalidArgumentException(
'Please set SIFT_SCIENCE_API_KEY and SIFT_SCIENCE_ACCOUNT_ID environment variables.'
);
}
$this->siftclient = new \SiftClient([
siftclient
'api_key' => $this->api_key,
'account_id' => $this->account_id,
]);
* Pass any method calls onto $this->siftclient
* @return mixed
public function __call($method, $args)
if (is_callable([$this->siftclient, $method])) {
return call_user_func_array([$this->siftclient, $method], $args);
} else {
throw new \BadMethodCallException("Method $method does not exist");
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: