for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Surge\LaravelSalesforce;
class SalesforceAuth
{
/**
* @var string
*/
public $id;
public $accessToken;
public $instanceUrl;
public $url;
* @var bool
private $authenticated = false;
public function isAuthenticated(): bool
return $this->authenticated;
}
public function __construct($client)
$this->client = $client;
client
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->login();
* Login.
private function login()
$body = [
'grant_type' => 'password',
'client_id' => config('sf.client_id'),
'client_secret' => config('sf.client_secret'),
'username' => config('sf.username'),
'password' => config('sf.password'),
];
$response = $this->client->post('https://login.salesforce.com/services/oauth2/token', [
'form_params' => $body,
])->getBody()->getContents();
$responseObject = \GuzzleHttp\json_decode($response);
$this->id = $responseObject->id;
$this->accessToken = $responseObject->access_token;
$this->instanceUrl = $responseObject->instance_url;
$this->url = $responseObject->instance_url.$this->version['url'];
version
if ($this->accessToken !== null) {
$this->authenticated = true;
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: