public function insert(Sample $sample) { if ($this->length) { $sample->setDiff($this->samples[$this->length - 1]); } $this->samples[] = $sample; $this->length++; }