for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Acacha\ForgePublish\Commands\Traits;
/**
* Trait ChecksToken.
*
* @package Acacha\ForgePublish\Commands\Traits
*/
trait ChecksToken
{
* Check token.
* @param $token
* @return bool
protected function checkToken($token)
try {
$response = $this->http->get($this->checkTokenURL(), [
http
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;
'headers' => [
'X-Requested-With' => 'XMLHttpRequest',
'Authorization' => 'Bearer ' . $token
]
]);
$content = json_decode($response->getBody()->getContents());
if (isset($content->message)) {
if ($content->message === 'Token is valid') {
return true;
}
} catch (\Exception $e) {
return false;
* Get api url endpoint.
protected function checkTokenURL()
return config('forge-publish.url') . config('forge-publish.get_check_token_uri');
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: