Sha256: 20938c4f89debd1a635e5fb6b0eac87d579e4d24154b3661e79959639ece16a9

Contents?: true

Size: 1.71 KB

Versions: 10

Compression:

Stored size: 1.71 KB

Contents

<?php

namespace MtHaml\Node;

use MtHaml\NodeVisitor\NodeVisitorInterface;

/**
 * InterpolatedString Node
 *
 * Represents a ruby-like interpolated string. Children are Text and Insert
 * nodes.
 */
class InterpolatedString extends NodeAbstract
{
    protected $childs;

    public function __construct(array $position, array $childs = array())
    {
        parent::__construct($position);
        $this->childs = $childs;
    }

    /**
     * @param Text|Insert $child Child
     */
    public function addChild(NodeAbstract $child)
    {

        if (!$child instanceof Text && !$child instanceof Insert) {
            throw new \InvalidArgumentException(sprintf('Argument 1 passed to %s() must be an instance of MtHaml\Node\Text or MtHaml\Node\Insert, instance of %s given', __METHOD__, get_class($child)));
        }

        $this->childs[] = $child;
    }

    /**
     * @return Text|Insert
     */
    public function getChilds()
    {
        return $this->childs;
    }

    public function getNodeName()
    {
        return 'interpolated string';
    }

    public function accept(NodeVisitorInterface $visitor)
    {
        if (false !== $visitor->enterInterpolatedString($this)) {

            if (false !== $visitor->enterInterpolatedStringChilds($this)) {
                foreach ($this->getChilds() as $child) {
                    $child->accept($visitor);
                }
                $visitor->leaveInterpolatedStringChilds($this);
            }
            $visitor->leaveInterpolatedString($this);
        }
    }

    public function isConst()
    {
        foreach ($this->childs as $child) {
            if (!$child->isConst()) {
                return false;
            }
        }

        return true;
    }
}

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
guard-mthaml-0.4.0 vendor/mthaml/mthaml/lib/MtHaml/Node/InterpolatedString.php
guard-mthaml-0.3.1 vendor/mthaml/mthaml/lib/MtHaml/Node/InterpolatedString.php
guard-mthaml-0.3.0 vendor/mthaml/mthaml/lib/MtHaml/Node/InterpolatedString.php
guard-mthaml-0.2.5 vendor/mthaml/mthaml/lib/MtHaml/Node/InterpolatedString.php
guard-mthaml-0.2.4 vendor/mthaml/mthaml/lib/MtHaml/Node/InterpolatedString.php
guard-mthaml-0.2.3 vendor/mthaml/mthaml/lib/MtHaml/Node/InterpolatedString.php
guard-mthaml-0.2.2 vendor/mthaml/mthaml/lib/MtHaml/Node/InterpolatedString.php
guard-mthaml-0.2.1 vendor/mthaml/mthaml/lib/MtHaml/Node/InterpolatedString.php
guard-mthaml-0.2.0 vendor/mthaml/mthaml/lib/MtHaml/Node/InterpolatedString.php
guard-mthaml-0.1.0 vendor/mthaml/mthaml/lib/MtHaml/Node/InterpolatedString.php