Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. NumericLiteral.php

function NumericLiteral::setFormat

Sets node's numeric format

Parameters

string $format Format, one of the format constants:

Return value

$this

1 call to NumericLiteral::setFormat()
NumericLiteral::setValue in vendor/mck89/peast/lib/Peast/Syntax/Node/NumericLiteral.php
Sets node's value

File

vendor/mck89/peast/lib/Peast/Syntax/Node/NumericLiteral.php, line 172

Class

NumericLiteral
A node that represents a numeric literal.

Namespace

Peast\Syntax\Node

Code

public function setFormat($format) {
    $this->format = $format;
    switch ($format) {
        case self::BINARY:
            $this->raw = "0b" . decbin($this->value);
            break;
        case self::OCTAL:
            $this->raw = "0o" . decoct($this->value);
            break;
        case self::HEXADECIMAL:
            $this->raw = "0x" . dechex($this->value);
            break;
        default:
            $this->raw = (string) $this->value;
            break;
    }
    return $this;
}
RSS feed
Powered by Drupal