phpldapadmin/app/Classes/LDAP/Attribute/Factory.php

57 lines
1.7 KiB
PHP
Raw Normal View History

<?php
namespace App\Classes\LDAP\Attribute;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Log;
use App\Classes\LDAP\Attribute;
/**
* 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
*/
class Factory
{
private const LOGKEY = 'LAf';
/**
* Map of attributes to appropriate class
*/
public const map = [
2023-03-02 07:21:53 +00:00
'createtimestamp' => Internal\Timestamp::class,
'creatorsname' => Internal\EntryDN::class,
'entrycsn' => Internal\EntryCSN::class,
'entrydn' => Internal\EntryDN::class,
'entryuuid' => Internal\EntryUUID::class,
2023-03-02 07:21:53 +00:00
'gidnumber' => GidNumber::class,
'hassubordinates' => Internal\HasSubordinates::class,
2023-02-19 09:25:32 +00:00
'jpegphoto' => Binary\JpegPhoto::class,
2023-03-02 07:21:53 +00:00
'modifytimestamp' => Internal\Timestamp::class,
'modifiersname' => Internal\EntryDN::class,
'objectclass' => ObjectClass::class,
2023-03-02 07:21:53 +00:00
'structuralobjectclass' => Internal\StructuralObjectClass::class,
'subschemasubentry' => Internal\SubschemaSubentry::class,
'supportedcontrol' => Schema\OID::class,
'supportedextension' => Schema\OID::class,
'supportedfeatures' => Schema\OID::class,
'supportedsaslmechanisms' => Schema\Mechanisms::class,
2023-03-02 07:21:53 +00:00
'userpassword' => Password::class,
];
/**
* Create the new Object for an attribute
*
* @param string $attribute
* @param array $values
* @return Attribute
*/
public static function create(string $attribute,array $values): Attribute
{
$class = Arr::get(self::map,$attribute,Attribute::class);
Log::debug(sprintf('%s:Creating LDAP Attribute [%s] as [%s]',static::LOGKEY,$attribute,$class));
return new $class($attribute,$values);
}
}