51 return $this->element->getAttribute(
'id');
62 if ($level > $this->useNestingLimit) {
63 throw new \enshrined\svgSanitize\Exceptions\NestingException(
'Nesting level too high, aborting', 1570713498, null, $this->
getElement());
66 if (in_array($this, $subjects,
true)) {
70 foreach ($this->useCollection as $usage) {
71 if ($usage->getSubject()->hasInfiniteLoop($subjects, $level + 1)) {
83 if ($subject === $this) {
84 throw new \LogicException(
'Cannot add self usage', 1570713416);
87 if (isset($this->useCollection[$identifier])) {
88 $this->useCollection[$identifier]->increment();
91 $this->useCollection[$identifier] =
new Usage($subject);
99 if ($subject === $this) {
100 throw new \LogicException(
'Cannot add self as usage', 1570713417);
103 if (isset($this->usedInCollection[$identifier])) {
104 $this->usedInCollection[$identifier]->increment();
107 $this->usedInCollection[$identifier] =
new Usage($subject);
117 foreach ($this->useCollection as $use) {
118 $useCount = $use->getSubject()->countUse();
119 $count += $use->getCount() * ($accumulated ? 1 + $useCount : max(1, $useCount));
130 foreach ($this->usedInCollection as $usedIn) {
131 $count += $usedIn->getCount() * max(1, $usedIn->getSubject()->countUsedIn());
144 $elements = array_map(
function(
Usage $usage) {
148 $this->usedInCollection = [];
149 $this->useCollection = [];
__construct(\DOMElement $element, $useNestingLimit)
Subject constructor.
countUse($accumulated=false)
addUsedIn(Subject $subject)
clearInternalAndGetAffectedElements()
Clear the internal arrays (to free up memory as they can get big) and return all the child usages DOM...
hasInfiniteLoop(array $subjects=[], $level=1)