Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace Drupal\Core\TypedData\Plugin\DataType; use Drupal\Core\Datetime\DrupalDa..

Decoded Output download

<?php

namespace Drupal\Core\TypedData\Plugin\DataType;

use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\TypedData\Attribute\DataType;
use Drupal\Core\TypedData\Type\DateTimeInterface;

/**
 * The timestamp data type.
 */
#[DataType(
  id: "timestamp",
  label: new TranslatableMarkup("Timestamp"),
)]
class Timestamp extends IntegerData implements DateTimeInterface {

  /**
   * The data value as a UNIX timestamp.
   *
   * @var int
   */
  protected $value;

  /**
   * {@inheritdoc}
   */
  public function getDateTime() {
    if (isset($this->value)) {
      return DrupalDateTime::createFromTimestamp($this->value);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function setDateTime(DrupalDateTime $dateTime, $notify = TRUE) {
    $this->value = $dateTime->getTimestamp();
    // Notify the parent of any changes.
    if ($notify && isset($this->parent)) {
      $this->parent->onChange($this->name);
    }
  }

}
 ?>

Did this file decode correctly?

Original Code

<?php

namespace Drupal\Core\TypedData\Plugin\DataType;

use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\TypedData\Attribute\DataType;
use Drupal\Core\TypedData\Type\DateTimeInterface;

/**
 * The timestamp data type.
 */
#[DataType(
  id: "timestamp",
  label: new TranslatableMarkup("Timestamp"),
)]
class Timestamp extends IntegerData implements DateTimeInterface {

  /**
   * The data value as a UNIX timestamp.
   *
   * @var int
   */
  protected $value;

  /**
   * {@inheritdoc}
   */
  public function getDateTime() {
    if (isset($this->value)) {
      return DrupalDateTime::createFromTimestamp($this->value);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function setDateTime(DrupalDateTime $dateTime, $notify = TRUE) {
    $this->value = $dateTime->getTimestamp();
    // Notify the parent of any changes.
    if ($notify && isset($this->parent)) {
      $this->parent->onChange($this->name);
    }
  }

}

Function Calls

None

Variables

None

Stats

MD5 3fe40f4b26b36466c1a92e5c0bb57b43
Eval Count 0
Decode Time 83 ms