Returns a count of the number of tags in {@link $tags} that match the {@link $partial}

@param array      $tags    An array of Tag objects or tag strings
@param TagPartial $partial The partial to match against

@return integer
337179
public static function countTags(array $tags, $role)
    {
        if (empty($tags))
            return 0;

        $count = 0;
        foreach ($tags as $tag) {
            if (!($tag instanceof Tag))
                $tag = new Tag($tag);

            if (strcmp(ltrim($role, '#'), $tag->getTagRole()) === 0)
                $count++;
        }

        return $count;

    }
1035320
public function partial_count($section)
	{
		// return the defined partial count
		return array_key_exists($section, $this->partials) ? count($this->partials[$section]) : 0;
	}
262775
protected function findTagIndex(array $tokens, int $from, int $to, string $tagType): ?int
    {
        for ($i = $from + 1; $i < $to; $i++) {
            if ($tokens[$i]['code'] === $tagType) {
                return $i;
            }
        }

        return null;
    }
1023008
public function hasTag(Array $tags)
    {
        // if no tags were specified, the fixture should always be loaded
        if (count($this->tags) == 0 || count(array_intersect($this->tags, $tags)) > 0) {
            return true;
        }

        return false;
    }
985484
private function countFacts(Individual $individual, array $tags): int
    {
        $count = 0;

        foreach ($individual->facts($tags) as $fact) {
            if (!$fact->isPendingDeletion()) {
                $count++;
            }
        }

        return $count;
    }
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;
    }
632783
protected function filterTags()
    {
        $data       = array();
        $returndata = array();
        $predicates = array();
        $count      = 0;
        $arr        = $this->getData();
        if (!empty($this->templateVars['Page']) && !empty($this->templateVars['MaxRows'])) {
            $this->templateVars['StartItem'] = (($this->templateVars['Page']-1)*$this->templateVars['MaxRows']) +1;
            $this->templateVars['EndItem'] = ($this->templateVars['Page'])*$this->templateVars['MaxRows'];
        }

        $partial = $this->getTemplateVariable('Partial');

        $partials = array();
        if(!empty($partial)) {
            $partialsStr = explode(',',$partial);
            foreach($partialsStr as $partial)
                $partials[] = new TagPartial($partial);
        }

        if (!empty($arr))
            foreach ((array)$arr as $tag) {
                if (!empty($partials)) {
                    $found = false;
                    foreach($partials as $partial) {
                        if($this->TagsHelper->matchPartial($partial, $tag))
                        {
                            $found = true;
                            break;
                        }
                    }
                    if(!$found)
                        continue;
                }

                if (($this->getTemplateVariable('Status.eq') != null) &&
                  $tag['TagLinkStatus'] != $this->getTemplateVariable('Status.eq'))
                    continue;
                if (($this->getTemplateVariable('Status.isActive') != null) && empty($tag['TagLinkURL']))
                    continue;

                $data[] = $tag;
            }

        $this->templateVars['TotalRecords'] = sizeof($data);
        if (!empty($data))
            foreach ((array)$data as $row) {
                if (!empty($this->templateVars['StartItem']) && $this->templateVars['StartItem'] > ++$count)
                    continue;

                $returndata[] = $row['TagLinkNode'];

                if (!empty($this->templateVars['MaxRows']) && sizeof($returndata) >= $this->templateVars['MaxRows'])
                    break;
            }
        return $returndata;
    }
541010
protected function combine_correlated_tags($tags) {
        global $DB;
        $ids = array_map(function($t) {
            return $t->id;
        }, $tags);

        // Retrieve the correlated tags of this tag and correlated tags of all tags to be merged in one query
        // but store them separately. Calculate the list of correlated tags that need to be added to the current.
        list($sql, $params) = $DB->get_in_or_equal($ids);
        $params[] = $this->id;
        $records = $DB->get_records_select('tag_correlation', 'tagid '.$sql.' OR tagid = ?',
            $params, '', 'tagid, id, correlatedtags');
        $correlated = array();
        $mycorrelated = array();
        foreach ($records as $record) {
            $taglist = preg_split('/\s*,\s*/', trim($record->correlatedtags), -1, PREG_SPLIT_NO_EMPTY);
            if ($record->tagid == $this->id) {
                $mycorrelated = $taglist;
            } else {
                $correlated = array_merge($correlated, $taglist);
            }
        }
        array_unique($correlated);
        // Strip out from $correlated the ids of the tags that are already in $mycorrelated
        // or are one of the tags that are going to be combined.
        $correlated = array_diff($correlated, [$this->id], $ids, $mycorrelated);

        if (empty($correlated)) {
            // Nothing to do, ignore situation when current tag is correlated to one of the merged tags - they will
            // be deleted later and get_tag_correlation() will not return them. Next cron will clean everything up.
            return;
        }

        // Update correlated tags of this tag.
        $newcorrelatedlist = join(',', array_merge($mycorrelated, $correlated));
        if (isset($records[$this->id])) {
            $DB->update_record('tag_correlation', array('id' => $records[$this->id]->id, 'correlatedtags' => $newcorrelatedlist));
        } else {
            $DB->insert_record('tag_correlation', array('tagid' => $this->id, 'correlatedtags' => $newcorrelatedlist));
        }

        // Add this tag to the list of correlated tags of each tag in $correlated.
        list($sql, $params) = $DB->get_in_or_equal($correlated);
        $records = $DB->get_records_select('tag_correlation', 'tagid '.$sql, $params, '', 'tagid, id, correlatedtags');
        foreach ($correlated as $tagid) {
            if (isset($records[$tagid])) {
                $newcorrelatedlist = $records[$tagid]->correlatedtags . ',' . $this->id;
                $DB->update_record('tag_correlation', array('id' => $records[$tagid]->id, 'correlatedtags' => $newcorrelatedlist));
            } else {
                $DB->insert_record('tag_correlation', array('tagid' => $tagid, 'correlatedtags' => '' . $this->id));
            }
        }
    }
310248
public function runChecks($tags = [])
    {
        $errors = [];

        $checks = $this->getChecks();

        if (!empty($tags)) {
            $taggedChecks = [];
            foreach ($checks as $check) {
                // a check can have many tags
                // true if any of the tags provided appears in the check tags
                if (array_intersect($check['tags'], $tags)) {
                    $taggedChecks[] = $check;
                }
            }
            $checks = $taggedChecks;
        }

        foreach ($checks as $check) {
            $functionName = '';
            if (is_array($check['check'])) {
                if (count($check['check']) > 1) {
                    $obj = reset($check['check']);
                    $method = end($check['check']);
                    $functionName = get_class($obj).'::'.$method;
                } else {
                    $functionName = reset($check['check']);
                }
            }

            $errors = array_merge($errors, call_user_func($check['check']));

            assert(
                is_array($errors),
                sprintf(
                    'The function %s did not return a list. All functions registered ".
            "with the checks registry must return a list.',
                    $functionName
                )
            );
        }

        return $errors;
    }
89212
public function tag($tags)
    {
        return $this->proxy($this->parent, $this->storage, $this->storageName)
                    ->with($this->attributes(['tag' => $tags]));
    }
229100
public function countVotes ($tag = null, bool $with = true) : int
    {
        return $this->_Votes->countVotes(VoteUtil::tagsConvert($tag),$with);
    }
1235802
public static function matchTags(array $tags1, array $tags2)
    {
        if (count(self::diffTags($tags1, $tags2)) == 0 &&
            count(self::diffTags($tags2, $tags1)) == 0)
            return true;

        return false;

    }
382042
protected function checkTags($tags)
    {
        foreach ($tags as $key => $value) {
            if (strlen($key) > self::MAX_TAG_KEY_LENGTH) {
                throw new CException(sprintf(
                    'SentryClient does not allow tag keys that contain more than %d characters.',
                    self::MAX_TAG_KEY_LENGTH
                ));
            }
            if (strlen($value) > self::MAX_TAG_VALUE_LENGTH) {
                throw new CException(sprintf(
                    'SentryClient does not allow tag values that contain more than %d characters.',
                    self::MAX_TAG_VALUE_LENGTH
                ));
            }
        }
    }
942726
public function scopeWithTags($query, $tags)
    {
        $tags = $this->makeTagsArray($tags);

        foreach ($tags as $tag)
            $this->scopeWithTag($query, $tag);

        return $query;
    }
698745
public function getIdsMatchingTags($tags = array())
    {
        $first = true;
        $ids = array();
        foreach ($tags as $tag) {
            $res = $this->_query("SELECT DISTINCT(id) AS id FROM tag WHERE name='$tag'");
            if (!$res) {
                return array();
            }
            $rows = @sqlite_fetch_all($res, SQLITE_ASSOC);
            $ids2 = array();
            foreach ($rows as $row) {
                $ids2[] = $row['id'];
            }
            if ($first) {
                $ids = $ids2;
                $first = false;
            } else {
                $ids = array_intersect($ids, $ids2);
            }
        }
        $result = array();
        foreach ($ids as $id) {
            $result[] = $id;
        }
        return $result;
    }
219121
private function setPercentSize(\Jb\Bundle\TagCloudBundle\Model\Tag $tag, $max)
    {
        $percent = ($tag->getCounter() / $max) * 100;

        $weight = floor($percent / 10);

        if ($percent >= 5) {
            $weight++;
        }

        if ($percent >= 80 && $percent < 100) {
            $weight = 8;
        } elseif ($percent == 100) {
            $weight = 9;
        }

        $tag->setWeight($weight);
    }
144931
protected function isTagsMatchCondition($tags)
    {
        $satisfies = true;

        foreach (explode('&&', $this->filterString) as $andTags) {
            $satisfiesComma = false;

            foreach (explode(',', $andTags) as $tag) {
                $tag = str_replace('@', '', trim($tag));

                if ('~' === $tag[0]) {
                    $tag = mb_substr($tag, 1, mb_strlen($tag, 'utf8') - 1, 'utf8');
                    $satisfiesComma = !in_array($tag, $tags) || $satisfiesComma;
                } else {
                    $satisfiesComma = in_array($tag, $tags) || $satisfiesComma;
                }
            }

            $satisfies = (false !== $satisfiesComma && $satisfies && $satisfiesComma) || false;
        }

        return $satisfies;
    }