/*
Removes tags from the whole array

@returns array $this->_tagsArray
968446
protected function _remove()
	{
    $_tagsArray = array();
		foreach ($this->_tagsArray as $key => $value) {
			if (!in_array($value['tag'], $this->getRemoveTags())) {
				$_tagsArray[$value['tag']] = $value;
			}
		}
		$this->_tagsArray = array();
		$this->_tagsArray = $_tagsArray;
		return $this->_tagsArray;
	}
1361146
public function tags(): array
    {

        if (property_exists($this, 'tags')) {
            if (is_null($this->token))
                return array_merge($this->tags, ['public']);

            return array_merge($this->tags, ['character_id:' . $this->getCharacterId()]);
        }

        if (is_null($this->token))
            return ['unknown_tag', 'public'];

        return ['unknown_tag', 'character_id:' . $this->getCharacterId()];
    }
37602
public function retag($tagNames)
    {
        $tagNames = static::$taggingUtility->makeTagArray($tagNames);
        $currentTagNames = $this->tagNames();

        $deletions = array_diff($currentTagNames, $tagNames);
        $additions = array_diff($tagNames, $currentTagNames);

        $this->untag($deletions);

        foreach($additions as $tagName) {
            $this->addTag($tagName);
        }
    }
1135552
protected function getTagsFromSphinx()
    {
        if (is_array($this->searchResults) && count($this->searchResults)) {
            return array_map(
                function ($row) {
                    return $row['tags'];
                },
                $this->searchResults
            );
        } else {
            return array();
        }
    }
1003634
public function detachTags($tags)
    {
        $tags = static::convertToTags($tags);

        collect($tags)
            ->filter()
            ->each(function (Tag $tag) {
                $this->tags()->detach($tag);
            });

        return $this;
    }
544357
private function getAllTags()
    {
        if ($comment = $this->getDocComment()) {
            if (preg_match_all("/\@(\w+)(.*)/", $comment, $m)) {
                foreach ($m[0] as $i => $result) {
                    $tagName = $m[1][$i];
                    $tagValue = trim($m[2][$i]);
                    $this->setTag($tagName, $tagValue);
                }
            }
        }
    }
632333
public function detachTags($tags = null)
    {
        ! $tags || $tags = $this->parseTags($tags);

        $this->tags()->detach($tags);

        return $this;
    }
13880
public function removeTag($tag)
    {
        $index = array_search($tag, $this->tags);

        if ($index !== false) {
            array_splice($this->tags, $index, 1);
            $this->ref = null;
        }

        return $this;
    }
1300218
public function removeByTag($tags, $byIntersect = false) {
		if (is_array($tags)) {
			$tags = array_map([$this, 'prepareTag'], array_values($tags));
		} else {
			$tags = $this->prepareTag($tags);
		}
		
		$tagData = $this->getTagData($tags, $byIntersect);
		
		if ($tagData === null) {
			return true;
		}
		
		$result = $this->getBackend()->removeMany($tagData);
		
		if ($result === true && $byIntersect === false) {
			if (is_array($tags)) {
				$this->getTagHolderBackend()->removeMany($tags);
			} else {
				$this->getTagHolderBackend()->remove($tags);
			}
		}
		
		return $result;
	}
984675
private function sanitizeTags(array $tags)
    {
        $sanitized = [];

        foreach ($tags as $tag) {
            $sanitized[] = (string) $tag;
        }

        return $sanitized;
    }
1021650
public function selectByTags(array $tags)
    {
        $result = [];
        foreach ($this->array['Key2Tags'] as $key => $keyTags) {
            $found = true;
            foreach ($tags as $t) {
                if (array_search($t, $keyTags)===false) {
                    $found = false;
                }
            }

            if ($found) {
                $result[] = $key;
            }
        }

        return $result;
    }
771317
protected function sanitizeTags(array $tags)
    {
        foreach ($tags as $key => $value) {
            $tags[$key] = $this->sanitizeTag($value);
        }
        return $tags;
    }
168913
function delete_tags( $ids )
	{
		$params = array();
		if (is_array($ids) && !empty($ids)) {
			$params['ids'] = join(',', $ids);
		} else {
			$params['ids'] = $ids;
		}
		return $this->oauth->post( 'tags/destroy_batch', $params );
	}
520907
public function untag($tagNames=null)
    {
        if(is_null($tagNames)) {
            $tagNames = $this->tagNames();
        }

        $tagNames = static::$taggingUtility->makeTagArray($tagNames);

        foreach($tagNames as $tagName) {
            $this->removeTag($tagName);
        }

        if(static::shouldDeleteUnused()) {
            static::$taggingUtility->deleteUnusedTags();
        }
    }
449869
public function clear(): bool
    {
        if (!empty($this->tag)) {
            foreach ($this->tag as $tag) {
                $this->clearTag($tag);
            }
            return true;
        }

        $this->writeTimes++;

        $this->handler->flushDB();
        return true;
    }
972261
public function getAllTags()
    {
        $qb = $this->createQueryBuilder('c');

        $qb
            ->select('c.tags')
            ->where($qb->expr()->isNotNull('c.tags'))
            ->distinct()
        ;

        $tagStrings = array_map('current', $qb->getQuery()->getScalarResult());
        $distinctTags = array();

        foreach ($tagStrings as $tagString) {
            foreach (explode(',', $tagString) as $tag) {
                if (!in_array($tag, $distinctTags)) {
                    array_push($distinctTags, $tag);
                }
            }
        }

        return $distinctTags;
    }
1367210
public function clear()
    {
        $this->metaTags = [];
        $this->linkTags = [];
        $this->css = [];
        $this->cssFiles = [];
        $this->js = [];
        $this->jsFiles = [];
        static::$constants = [];
        $this->placeholders = [];
    }