Code Duplication    Length = 18-18 lines in 4 locations

src/app/Balloon.App.Convert/AttributeDecorator.php 1 location

@@ 114-131 (lines=18) @@
111
    /**
112
     * Execute closures.
113
     */
114
    protected function translateAttributes(array $slave, array $attributes): array
115
    {
116
        foreach ($attributes as $key => &$value) {
117
            if ($value instanceof Closure) {
118
                $result = $value->call($this, $slave);
119
120
                if (null === $result) {
121
                    unset($attributes[$key]);
122
                } else {
123
                    $value = $result;
124
                }
125
            } elseif ($value === null) {
126
                unset($attributes[$key]);
127
            }
128
        }
129
130
        return $attributes;
131
    }
132
}
133

src/lib/Filesystem/DeltaAttributeDecorator.php 1 location

@@ 71-88 (lines=18) @@
68
    /**
69
     * Execute closures.
70
     */
71
    protected function translateAttributes(array $node, array $attributes): array
72
    {
73
        foreach ($attributes as $key => &$value) {
74
            if ($value instanceof Closure) {
75
                $result = $value->call($this, $node);
76
77
                if (null === $result) {
78
                    unset($attributes[$key]);
79
                } else {
80
                    $value = $result;
81
                }
82
            } elseif ($value === null) {
83
                unset($attributes[$key]);
84
            }
85
        }
86
87
        return $attributes;
88
    }
89
}
90

src/app/Balloon.App.Notification/AttributeDecorator.php 1 location

@@ 130-147 (lines=18) @@
127
    /**
128
     * Execute closures.
129
     */
130
    protected function translateAttributes(array $message, array $attributes): array
131
    {
132
        foreach ($attributes as $key => &$value) {
133
            if ($value instanceof Closure) {
134
                $result = $value->call($this, $message);
135
136
                if (null === $result) {
137
                    unset($attributes[$key]);
138
                } else {
139
                    $value = $result;
140
                }
141
            } elseif ($value === null) {
142
                unset($attributes[$key]);
143
            }
144
        }
145
146
        return $attributes;
147
    }
148
}
149

src/lib/Filesystem/Node/AttributeDecorator.php 1 location

@@ 285-302 (lines=18) @@
282
    /**
283
     * Execute closures.
284
     */
285
    protected function translateAttributes(NodeInterface $node, array $attributes): array
286
    {
287
        foreach ($attributes as $key => &$value) {
288
            if ($value instanceof Closure) {
289
                $result = $value->call($this, $node);
290
291
                if (null === $result) {
292
                    unset($attributes[$key]);
293
                } else {
294
                    $value = $result;
295
                }
296
            } elseif ($value === null) {
297
                unset($attributes[$key]);
298
            }
299
        }
300
301
        return $attributes;
302
    }
303
}
304