public function getVotesList($tag = null, bool $with = true) : array { if ($tag === null) { return $this->getFullDataSet(); } else { $tag = Vote::tagsConvert($tag); if ($tag === null) { $tag = []; } $search = []; foreach ($this as $key => $value) { $noOne = true; foreach ($tag as $oneTag) { if ($oneTag === $key || in_array($oneTag, $value->getTags(), true)) { if ($with) { $search[$key] = $value; break; } else { $noOne = false; } } } if (!$with && $noOne) { $search[$key] = $value; } } return $search; } }
public function removeVote($in, bool $with = true) : array { $rem = []; if ($in instanceof Vote) { $key = $this->getVoteKey($in); if ($key !== false) { $this->_Votes[$key]->destroyLink($this); $rem[] = $this->_Votes[$key]; unset($this->_Votes[$key]); } } else { // Prepare Tags $tag = Vote::tagsConvert($in); // Deleting foreach ($this->getVotesList($tag, $with) as $key => $value) { $this->_Votes[$key]->destroyLink($this); $rem[] = $this->_Votes[$key]; unset($this->_Votes[$key]); } } return $rem; }