for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Alish\LaravelOtp\Drivers;
use Illuminate\Support\Arr;
trait HasConfig
{
protected function tokenType(): string
return $this->getConfig('type', 'alphanumeric');
}
protected function tokenLength(): int
return $this->getConfig('length', 6);
protected function timeout(): ?int
return $this->getConfig('timeout', null);
protected function customSet(): ?string
return $this->getConfig('custom', null);
protected function shouldHash(): bool
return Arr::get($this->config, 'hash', false);
config
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;
protected function sensitiveCase()
return Arr::get($this->config, 'case-sensitive', true);
protected function getConfig(string $key, $default)
return property_exists($this, 'config') ?
Arr::get($this->config, $key, $default) :
$default;
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: