# Class yii\twig\html\StyleClassNode

Inheritance | yii\twig\html\StyleClassNode » yii\twig\html\BaseClassNode » Twig\Node\Node
Source Code | https://github.com/yiisoft/yii2-twig/blob/master/html/StyleClassNode.php

## Public Methods

Hide inherited methods

Method | Description | Defined By
--- | --- | ---
__construct() |  | yii\twig\html\StyleClassNode
compile() |  | yii\twig\html\BaseClassNode
getHelperMethod() |  | yii\twig\html\StyleClassNode

## Method Details

Hide inherited methods

__construct() public method

public void __construct ( \Twig\Token $name, $value, \Twig\Token $operator, $lineno = 0, $tag = null )
$name |  |
$value |  |
$operator |  |
$lineno |  |
$tag |  |

Source code

                    public function __construct(Token $name, $value, Token $operator, $lineno = 0, $tag = null)
    {
        parent::__construct(array('value' => $value), array('name' => $name, 'operator' => $operator), $lineno, $tag);
    }

compile() public method

Defined in: yii\twig\html\BaseClassNode::compile()

public void compile ( \Twig\Compiler $compiler )
$compiler |  |

Source code

                    public function compile(Compiler $compiler)
    {
        $name = $this->getAttribute('name')->getValue();
        $method = $this->getHelperMethod();
        $compiler
            ->addDebugInfo($this)
            ->write("\yii\helpers\Html::{$method}(\$context[\"{$name}\"],")
            ->subcompile($this->getNode('value'))
            ->raw(");\n");
    }

getHelperMethod() public method

public void getHelperMethod ( )

Source code

                    public function getHelperMethod()
    {
        $operator = $this->getAttribute('operator')->getValue();
        switch ($operator) {
            case '+':
                return 'addCssStyle';
            case '-':
                return 'removeCssStyle';
            default:
                throw new Error("Operator {$operator} no found;");
        }
    }