QuackCompiler\Parser\Parser::indent PHP Method

indent() public method

public indent ( )
    public function indent()
    {
        return str_repeat('  ', $this->scope_level);
    }

Usage Example

Example #1
0
 public function format(Parser $parser)
 {
     $source = 'when';
     $source .= PHP_EOL;
     $parser->openScope();
     for ($i = 0, $l = sizeof($this->cases); $i < $l; $i++) {
         $obj = $this->cases[$i];
         $source .= $parser->indent();
         $source .= '| ';
         if (null !== $obj->condition) {
             $source .= $obj->condition->format($parser);
             $source .= ' -> ';
         } else {
             $source .= 'else ';
         }
         $source .= $obj->action->format($parser);
         if ($i + 1 !== $l) {
             $source .= ';';
             $source .= PHP_EOL;
         }
     }
     $parser->closeScope();
     $source .= PHP_EOL;
     $source .= $parser->indent();
     $source .= 'end';
     return $this->parenthesize($source);
 }
All Usage Examples Of QuackCompiler\Parser\Parser::indent