MOON
Server: Apache
System: Linux res.emeff.ca 3.10.0-962.3.2.lve1.5.24.10.el7.x86_64 #1 SMP Wed Mar 20 07:36:02 EDT 2019 x86_64
User: accemeff (1004)
PHP: 7.0.33
Disabled: NONE
Upload Files
File: /home/accemeff/vendor/craftcms/cms/src/models/AssetTransformIndex.php
<?php
/**
 * @link https://craftcms.com/
 * @copyright Copyright (c) Pixel & Tonic, Inc.
 * @license https://craftcms.github.io/license/
 */

namespace craft\models;

use Craft;
use craft\base\Model;
use craft\validators\DateTimeValidator;
use yii\base\InvalidConfigException;

/**
 * Class AssetTransformIndex model.
 *
 * @property AssetTransform $transform
 * @author Pixel & Tonic, Inc. <support@pixelandtonic.com>
 * @since 3.0
 */
class AssetTransformIndex extends Model
{
    // Properties
    // =========================================================================

    /**
     * @var int|null ID
     */
    public $id;

    /**
     * @var int|null File ID
     */
    public $assetId;

    /**
     * @var int|null Volume ID
     */
    public $volumeId;

    /**
     * @var string|null Filename
     */
    public $filename;

    /**
     * @var string|null Format
     */
    public $format;

    /**
     * @var string|null Location
     */
    public $location;

    /**
     * @var bool File exists
     */
    public $fileExists = false;

    /**
     * @var bool In progress
     */
    public $inProgress = false;

    /**
     * @var \DateTime|null Date indexed
     */
    public $dateIndexed;

    /**
     * @var \DateTime|null Date updated
     */
    public $dateUpdated;

    /**
     * @var \DateTime|null Date created
     */
    public $dateCreated;

    /**
     * @var string|null Detected format
     */
    public $detectedFormat;

    /**
     * @var AssetTransform|null The transform associated with this index
     */
    private $_transform;

    // Public Methods
    // =========================================================================

    /**
     * @inheritdoc
     */
    public function datetimeAttributes(): array
    {
        $attributes = parent::datetimeAttributes();
        $attributes[] = 'dateIndexed';
        return $attributes;
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        $rules = parent::rules();
        $rules[] = [['id', 'assetId', 'volumeId'], 'number', 'integerOnly' => true];
        $rules[] = [['dateIndexed', 'dateUpdated', 'dateCreated'], DateTimeValidator::class];
        return $rules;
    }

    /**
     * Use the folder name as the string representation.
     *
     * @return string
     */
    public function __toString(): string
    {
        return (string)$this->id;
    }

    /**
     * Returns the transform associated with this index.
     *
     * @return AssetTransform
     * @throws InvalidConfigException if [[location]] is invalid
     */
    public function getTransform(): AssetTransform
    {
        if ($this->_transform !== null) {
            return $this->_transform;
        }

        if (($this->_transform = Craft::$app->getAssetTransforms()->normalizeTransform(mb_substr($this->location, 1))) === null) {
            throw new InvalidConfigException('Invalid transform location: ' . $this->location);
        }

        return $this->_transform;
    }

    /**
     * Sets the transform associated with this index.
     *
     * @param AssetTransform $transform
     */
    public function setTransform(AssetTransform $transform)
    {
        $this->_transform = $transform;
    }
}