CoreFiles by mySites.guru
ConstStub.php52 lines, 1,168 bytes, from Joomla_6.2.0-alpha2-Alpha-Full_Package.zip
Raw History Compare with 6.2.0-alpha1
md5
a211cc276b24f4aefbce1f48cd1d4318
sha1
e90631352fc73eb746c25ebd2d5801e57011fada
sha256
cb9bac8f1bc0a310cde4ec81fdf21f177017602526ab460a7a55d64d018784ce
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\VarDumper\Caster;

use Symfony\Component\VarDumper\Cloner\Stub;

/**
 * Represents a PHP constant and its value.
 *
 * @author Nicolas Grekas <[email protected]>
 */
class ConstStub extends Stub
{
    public function __construct(string $name, string|int|float|null $value = null)
    {
        $this->class = $name;
        $this->value = 1 < \func_num_args() ? $value : $name;
    }

    public function __toString(): string
    {
        return (string) $this->value;
    }

    /**
     * @param array<int, string> $values
     */
    public static function fromBitfield(int $value, array $values): self
    {
        $names = [];
        foreach ($values as $v => $name) {
            if ($value & $v) {
                $names[] = $name;
            }
        }

        if (!$names) {
            $names[] = $values[0] ?? 0;
        }

        return new self(implode(' | ', $names), $value);
    }
}

The same content is in 49 releases, Joomla 6.0.0-beta1 to 6.3.0-alpha1. See them all, or every version of this file.