for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace ByTIC\Hello\Models\Clients\PersonalAccess;
use ByTIC\Hello\Models\Clients\Client;
use ByTIC\Hello\Utility\ClientsHelper;
use ByTIC\Hello\Utility\GrantsHelper;
use ByTIC\Hello\Utility\ModelsHelper;
/**
* Class ClientsManager
* @package ByTIC\Hello\Models\Clients\PersonalAccess
*/
class ClientsManager
{
protected static $client = null;
* @return \ByTIC\Hello\Models\Clients\Client
public static function get()
if (static::$client !== null) {
return static::$client;
}
if (ClientsHelper::$personalAccessClientId > 0) {
$client = ModelsHelper::clients()->findOne(ClientsHelper::$personalAccessClientId);
if ($client instanceof Client) {
static::$client = $client;
return $client;
$clients = ModelsHelper::clients()->findByRedirect(ClientsHelper::PERSONAL_ACCESS_REDIRECT_URI);
if (count($clients) === 1) {
static::$client = $clients->current();
return $clients->current();
return $clients->current()
Nip\Records\AbstractMode...ections\Collection|true
ByTIC\Hello\Models\Clients\Client
static::$client = static::create();
public static function resetClient()
static::$client = null;
* @param string $name
* @return Client
public static function create($name = null)
$client = ModelsHelper::clients()->getNew();
$name = empty($name) ? 'Personal Access Client' : $name;
$client->setName($name);
$client->addGrants(GrantsHelper::GRANT_TYPE_PERSONAL_ACCESS);
$client->setRedirectUri(ClientsHelper::PERSONAL_ACCESS_REDIRECT_URI);
$client->save();