Adldap\Query\Processor::newLdapEntry PHP Method

newLdapEntry() public method

Returns a new LDAP Entry instance.
public newLdapEntry ( array $attributes = [] ) : Entry
$attributes array
return Adldap\Models\Entry
    public function newLdapEntry(array $attributes = [])
    {
        $attribute = $this->schema->objectClass();
        if (array_key_exists($attribute, $attributes) && array_key_exists(0, $attributes[$attribute])) {
            // Retrieve all of the object classes from the LDAP
            // entry and lowercase them for comparisons.
            $classes = array_map('strtolower', $attributes[$attribute]);
            // Retrieve the model mapping.
            $models = $this->map();
            // Retrieve the object class mappings (with strtolower keys).
            $mappings = array_map('strtolower', array_keys($models));
            // Retrieve the model from the map using the entry's object class.
            $map = array_intersect($mappings, $classes);
            if (count($map) > 0) {
                // Retrieve the model using the object class.
                $model = $models[current($map)];
                // Construct and return a new model.
                return $this->newModel([], $model)->setRawAttributes($attributes);
            }
        }
        // A default entry model if the object category isn't found.
        return $this->newModel()->setRawAttributes($attributes);
    }