public function addClass($className) { if (!$className) { return $this; } foreach ($this->stack(1) as $node) { if (!$this->is(".{$className}", $node)) { $node->setAttribute('class', trim($node->getAttribute('class') . ' ' . $className)); } } return $this; }