Skip to content
This repository was archived by the owner on Apr 24, 2020. It is now read-only.

Commit c3022e7

Browse files
committedNov 19, 2019
Only transform attributes that have transformers
1 parent aaf6359 commit c3022e7

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed
 

‎app/Ldap/Transformers/AttributeTransformer.php

+15-3
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@ class AttributeTransformer extends Transformer
2929
*/
3030
public function transform(): array
3131
{
32-
// Here we will go through each LDAP attribute and attempt
33-
// converting the value depending on the attribute map.
34-
foreach ($this->value as $attribute => $value) {
32+
foreach ($this->getAttributesToTransform() as $attribute) {
3533
if (array_key_exists($attribute, $this->map)) {
3634
$transformer = $this->map[$attribute];
35+
$value = $this->value[$attribute];
3736

3837
// Transform and replace the value with the transformed value.
3938
$this->value[$attribute] = (new $transformer(Arr::wrap($value)))->transform();
@@ -42,4 +41,17 @@ public function transform(): array
4241

4342
return $this->value;
4443
}
44+
45+
/**
46+
* Get the attributes to transform.
47+
*
48+
* @return array
49+
*/
50+
protected function getAttributesToTransform()
51+
{
52+
return array_intersect(
53+
array_keys($this->value),
54+
array_keys($this->map)
55+
);
56+
}
4557
}

0 commit comments

Comments
 (0)
This repository has been archived.