mathiasverraes/classfunctions

用于操作类名的函数

1.1.0 2014-07-28 14:39 UTC

This package is auto-updated.

Last update: 2024-08-24 22:30:30 UTC


README

PHP工具,用于获取类名的不同变体

use Verraes\ClassFunctions;

// Fully qualified class name of an object, without a leading backslash
ClassFunctions\fqcn($object);

// Canonical class name of an object, of the form "My.Namespace.MyClass"
ClassFunctions\canonical($object);

// Underscored and lowercased class name of an object, of the form "my.namespace.my_class"
ClassFunctions\underscore($object);

// The class name of an object, without the namespace
ClassFunctions\short($object);

上述方法也接受字符串,并且ClassFunctions\fqcn()接受从ClassFunctions\canonical()返回的标准类名。

免费附加功能

// Returns an associative array of 'CONSTANT_NAME' => 'value'
ClassFunctions\constants('Verraes\ClassFunctions\Tests\MyClass')

安装

您可以使用Composer安装ClassFunctions

composer require mathiasverraes/classfunctions

运行composer installcomposer update,然后您就可以开始使用了。