2021-12-08 12:26:12 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Classes\LDAP\Attribute;
|
|
|
|
|
|
|
|
use Illuminate\Support\Arr;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
use App\Classes\LDAP\{Attribute};
|
|
|
|
|
2021-12-10 11:39:09 +00:00
|
|
|
/**
|
|
|
|
* This factory is used to return LDAP attributes as an object
|
|
|
|
*
|
|
|
|
* If there is no specific Attribute defined, then the default Attribute::class is return
|
|
|
|
*/
|
2021-12-08 12:26:12 +00:00
|
|
|
class Factory
|
|
|
|
{
|
|
|
|
private const LOGKEY = 'LAf';
|
|
|
|
|
|
|
|
/**
|
2021-12-10 11:39:09 +00:00
|
|
|
* Map of attributes to appropriate class
|
2021-12-08 12:26:12 +00:00
|
|
|
*/
|
|
|
|
public const map = [
|
|
|
|
'jpegphoto'=>Attribute\Binary\JpegPhoto::class,
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
2021-12-10 11:39:09 +00:00
|
|
|
* Create the new Object for an attribute
|
2021-12-08 12:26:12 +00:00
|
|
|
*
|
|
|
|
* @param string $attribute
|
|
|
|
* @param array $values
|
|
|
|
* @return Attribute
|
|
|
|
*/
|
|
|
|
public static function create(string $attribute,array $values): Attribute
|
|
|
|
{
|
|
|
|
$class = Arr::get(self::map,strtolower($attribute),Attribute::class);
|
|
|
|
Log::debug(sprintf('%s:Creating LDAP Attribute [%s] as [%s]',static::LOGKEY,$attribute,$class));
|
|
|
|
|
|
|
|
return new $class($attribute,$values);
|
|
|
|
}
|
|
|
|
}
|