key = $key; $this->data = $data; } /** * Compare node data * * @param mixed $data Node data to compare with * * @return -1|0|1 * * @since 1.0.0 */ public function compare(mixed $data) : int { return $this->data <=> $data; } /** * To array * * @return array * * @since 1.0.0 */ public function toArray() : array { return [ 'key' => $this->key, 0 => $this->left?->toArray(), 1 => $this->right?->toArray(), ]; } }