# give/4.16.9/src/Framework/FieldsAPI/Concerns/RemoveNode.php

GiveWP – Donation Plugin and Fundraising Platform, version 4.16.9. 33 lines.

- Page: https://pluginprobe.com/plugins/give/4.16.9/code/src/Framework/FieldsAPI/Concerns/RemoveNode.php
- Raw: https://pluginprobe.com/plugins/give/4.16.9/raw/src/Framework/FieldsAPI/Concerns/RemoveNode.php
- Modified: 2023-10-16T17:55:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/give/4.16.9/code/src/Framework/FieldsAPI/Concerns/RemoveNode.php#L10-L20`.

```php
<?php

namespace Give\Framework\FieldsAPI\Concerns;

use Give\Framework\FieldsAPI\Contracts\Collection;

trait RemoveNode
{
    /**
     * @since 3.0.0 preserve array numeric keys
     * @since 2.10.2
     *
     * @return static
     */
    public function remove(string $name)
    {
        foreach ($this->nodes as $index => $node) {
            if ($node->getName() === $name) {
                unset($this->nodes[$index]);
                $this->nodes = array_values($this->nodes);

                return $this;
            }
            if ($node instanceof Collection) {
                return $node->remove($name);
            }
        }

        // Maybe need to throw an exception if no node is removed.
        return $this;
    }
}

```
