src/Datastructure/Lists/LinkedLists/SinglyLinkedList.php
public function prepend(?Node $node): bool {
        if ($node === null) {
            return false;
        }
        $node->setNext($this->getHead());
        $this->setHead($node);
        return true;
    }
public function prepend(?Node $node): bool {
        if ($node === null) {
            return false;
        }
        $node->setNext($this->getHead());
        $this->setHead($node);
        return true;
    }
public function prepend ( ? Node $ node ) : bool { if ( $ node === null ) { return false ; } $ node -> setNext ( $ this -> getHead ( ) ) ; $ this -> setHead ( $ node ) ; return true ; }
the prepend method simply checks first if the node is still valid.
If it does not equal to null, the next pointer of the new node is
set to head and the head is set to the new node in order to create
the new head.

@param \doganoo\PHPAlgorithms\Datastructure\Lists\Node $node
@return bool
the prepend method simply checks first if the node is still valid . If it does not equal to null the next pointer of the new node is set to head and the head is set to the new node in order to create the new head .