public function addChild(MessagePart $part, $position = null)
    {
        if ($part !== $this) {
            $part->parent = $this;
            array_splice(
                $this->children,
                ($position === null) ? count($this->children) : $position,
                0,
                [ $part ]
            );
            $this->onChange();
        }
    }
public function addChild(MessagePart $part, $position = null)
    {
        if ($part !== $this) {
            $part->parent = $this;
            array_splice(
                $this->children,
                ($position === null) ? count($this->children) : $position,
                0,
                [ $part ]
            );
            $this->onChange();
        }
    }
public function addChild ( MessagePart $ part , $ position = null ) { if ( $ part !== $ this ) { $ part -> parent = $ this ; array_splice ( $ this -> children , ( $ position === null ) ? count ( $ this -> children ) : $ position , 0 , [ $ part ] ) ; $ this -> onChange ( ) ; } }
Registers the passed part as a child of the current part.

If the $position parameter is non-null, adds the part at the passed
position index.

@param MessagePart $part
@param int $position
Registers the passed part as a child of the current part .