for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is a part of GraphQL project.
*
* @author Alexandr Viniychuk <[email protected]>
* created: 5/4/16 9:18 PM
*/
namespace Youshido\GraphQL\Type\Traits;
use Youshido\GraphQL\Field\FieldInterface;
/**
* Class AutoNameTrait
* @package Youshido\GraphQL\Type\Traits
trait AutoNameTrait
{
public function getName()
if (!empty($this->config)) {
return $this->config->getName();
config
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
$className = get_called_class();
if ($prevPos = strrpos($className, '\\')) {
$className = substr($className, $prevPos + 1);
if (substr($className, -5) == 'Field') {
$className = lcfirst(substr($className, 0, -5));
} elseif (substr($className, -4) == 'Type') {
$className = substr($className, 0, -4);
if ($this instanceof FieldInterface) {
$className = lcfirst($className);
return $className;
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: