Gets a class name for a given class or instance.

@param mixed $value

@return string

@throws InvalidArgumentException If the class does not exists
172578
private function getClass($value)
    {
        if (\is_string($value)) {
            if (!class_exists($value) && !interface_exists($value, false)) {
                throw new InvalidArgumentException(sprintf('The class or interface "%s" does not exist.', $value));
            }

            return ltrim($value, '\\');
        }

        if (!\is_object($value)) {
            throw new InvalidArgumentException(sprintf('Cannot create metadata for non-objects. Got: "%s"', \gettype($value)));
        }

        return \get_class($value);
    }
882876
public static function fromValue($value)
    {
        $values = static::getValues();
        if (array_key_exists($value, $values)) {
            return new static($values[$value], $value);
        }
        throw new \InvalidArgumentException("No enum constant value '$value' class " . get_called_class());
    }
545263
static function ByValue($value)
    {
        $calledClass = get_called_class();
        $allowed = self::AllowedClassValues($calledClass);
        if (!in_array($value, $allowed, true))
            throw new \InvalidArgumentException('Value ' . $value . ' not allowed for enum ' . $calledClass);
        
        return new $calledClass($value);
    }
490068
public static function getName($code)
    {
        if (!isset(self::$codesDescriptions[$code])) {
            throw new InvalidArgumentException("Invalid code $code specified");
        }

        return self::$codesDescriptions[$code];
    }
593388
protected function castToClass($value)
    {
        if (!class_exists($this->class)) {
            return $this->dontCast($value, "Class doesn't exist");
        }

        if (is_object($value) && is_a($value, $this->class)) {
            return $value;
        }

        $value = $this->createWithSetState($value);

        if (!is_a($value, $this->class)) {
            $class = $this->class;
            $value = new $class($value);
        }

        return $value;
    }
429447
public static function getNameForValue($value)
    {
        foreach (self::getConstants() as $constant) {
            if ($constant['value'] === $value) {
                return $constant['name'];
            }
        }
        return false;
    }
977742
public function getConfigurationParameterName($value = null)
    {
        $output = '';

        if (!empty($this->_parent) && $this->_parent instanceof Parameter) {
            $output .= $this->_parent->getConfigurationParameterName();
        }

        if (!empty($this->_name)) {
            if (!empty($output)) $output .= '->';

            $output .= $this->_name;
        } else {
            if (!empty($output)) $output .= '->';

            $output .= '{unspecified}';
        }

        if (!empty($value)) {
            if (!empty($output)) $output .= '->';

            $output .= $value;
        }

        return $output;
    }
1263210
public static function qualifiedClassName($className, $namespace)
    {
        if (empty($className)) {
            throw new \InvalidArgumentException('Class name cannot be empty.');
        }

        if (empty($namespace)) {
            throw new \InvalidArgumentException('Current namespace cannot be empty.');
        }

        $className = trim($className, '\\');
        $len = strlen($namespace);

        if (strlen($className) > $len && ($namespace . '\\') === substr($className, 0, $len + 1)) {
            return substr($className, $len + 1);
        }

        return $className;
    }
620328
public function setValue($value)
    {
        if (!is_string($value) || (is_object($value) && !method_exists($value, "__toString"))) {
            throw new InvalidArgumentException(sprintf(
                "Invalid argument given to %s, expected a string, %s given",
                __METHOD__,
                is_object($value) ? get_class($value) : gettype($value)
            ));
        }

        $value = (string) $value;

        if (null !== $regex = $this->getValidationRegex()) {
            if (! preg_match($regex, $value)) {
                throw new InvalidArgumentException(sprintf(
                    "The given value '%s' doesn't match the validation regular expression: %s",
                    $value,
                    $regex
                ));
            }
        }

        $this->value = $value;

        return $this;
    }
585314
private function getValueAsString($value): string
    {
        if (is_bool($value)) {
            return $value ? 'true' : 'false';
        }

        if (is_float($value)) {
            $value = (string) $value;
            if (false === strpos($value, '.')) {
                $value .= '.0';
            }

            return $value;
        }

        if (is_int($value)) {
            return (string) $value;
        }

        throw new \InvalidArgumentException(sprintf('Unsupported data type: %s', gettype($value)));
    }
1361610
private static function getLabel($value)
    {
        self::bootClass();

        if (static::hasLabels() && isset(static::$labels[$value])) {
            return (string) static::$labels[$value];
        }

        return (string) $value;
    }
323388
public function getNameAttribute($value)
    {

        if (! $this->type)
            return null;

        if (is_null($value) || $value == '')
            return $this->type->typeName;

        return $value;
    }
779692
public function getReflClassFromComparisonValue( $value )
    {

        if( is_array($value) ) {
            $class = $this->namespace . '\\FindFilterComponent\\PropertyAccessArrayEquality';
        } elseif ( is_object($value) and $value instanceof Container ) {
            $class = $this->namespace . '\\FindFilterComponent\\PropertyAccessContainerEquality';
        } else {
            $class = $this->namespace . '\\FindFilterComponent\\PropertyAccessScalarEquality';
        }
        return new ReflectionClass($class);
    }
115260
protected function _getType($value)
    {
        if (is_object($value)) {
            try {
                return self::getShortClassname($value);
            } catch (\InvalidArgumentException $e) {
                return null;
            }
        }

        if (is_array($value)) {
            return 'array';
        }

        return 'scalar';
    }
728344
public function normalizeValue($value)
	{
		if (is_string($value) && class_exists($value))
		{
			$value = new $value($this->configurator);
		}

		if ($value instanceof ConfiguratorBase)
		{
			return $value;
		}

		throw new InvalidArgumentException('PluginCollection::normalizeValue() expects a class name or an object that implements s9e\\TextFormatter\\Plugins\\ConfiguratorBase');
	}
437168
public function getType($value)
    {
        if (strpos($value, '\\') !== false && class_exists($value)) {
            return self::TYPE_CLASS;
        } else {
            return self::TYPE_SCALAR;
        }
    }
239416
protected function getValueType($value)
    {
        switch (true) {
            case is_scalar($value):
                $type = gettype($value);
                break;

            case is_array($value):
                $type = 'array';
                break;

            case is_object($value):
                $type = get_class($value);
                break;

            case is_resource($value):
                $type = 'resource';
                break;

            default:
                $type = 'unknown';
                break;
        }

        return $type;
    }