Set the trait name to use.

@param string $traitClass The trait class to use.
@return \Wingu\OctopusCore\CodeGenerator\PHP\OOP\UseTraitGenerator
@throws \Wingu\OctopusCore\CodeGenerator\Exceptions\InvalidArgumentException If the use is not valid.
979213
public function setTraitClass($traitClass)
    {
        if ($this->isObjectNameValid($traitClass) !== true) {
            throw new InvalidArgumentException('The name of the trait to use is not valid.');
        }

        $this->traitClass = $traitClass;

        return $this;
    }
756610
private static function _getTraits($class, array $traits = null)
    {
        $rc = $class instanceof \ReflectionClass ? $class : new \ReflectionClass($class);
        if (is_null($traits)) {
            $traits = array();
        }

        // traits being embedded through the current class or the embedded traits
        foreach ($rc->getTraits() as $trait) {
            $traits = self::_getTraits($trait, $traits); // first the embedded traits that come first...
            if (!in_array($trait->name, $traits)) {
                $traits[] = $trait->name;
            }                    // then the current trait
        }

        // traits embedded by the parent class
        if ($rc->getParentClass()) {
            $traits = self::_getTraits($rc->getParentClass(), $traits);
        }

        return $traits;
    }
764928
protected function prepareTraits(array $traits)
    {
        \natcasesort($traits);

        // My kingdom for a generator.
        $ret = [];

        foreach ($traits as $name) {
            if ($this->showItem($name)) {
                $ret[$name] = [
                    'name'  => $name,
                    'style' => self::IS_CLASS,
                    'value' => $this->presentSignature($name),
                ];
            }
        }

        return $ret;
    }
1003685
protected function addClass(string $class)
    {
        if ($this->initialized) {
            throw new RuntimeException("You can't register provider class as registry as been initialized.");
        }

        if (!class_exists($class)) {
            throw new InvalidArgumentException("Class $class does not exist.");
        }

        if (!is_subclass_of($class, ProviderInterface::class)) {
            throw new InvalidArgumentException("Class $class must implement " . ProviderInterface::class);
        }

        $this->classes[] = $class;
    }
274556
protected static function traitsOfTrait($trait)
    {
        $traits = static::traits($trait, false, false);

        foreach ($traits as $usedTrait) {
            $traits += static::traitsOfTrait($usedTrait);
        }

        return $traits;
    }
1014973
public function setSenderType($senderType)
    {
        $allowedValues = $this->getSenderTypeAllowableValues();
        if (!in_array($senderType, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'senderType', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['senderType'] = $senderType;

        return $this;
    }
93338
public function setDataObjectClass($class)
    {
        if (!$class) {
            throw new InvalidArgumentException("Missing class provided");
        }

        if (!class_exists($class)) {
            throw new InvalidArgumentException("Non-existent classname \"{$class}\"");
        }

        if (!is_subclass_of($class, DataObject::class)) {
            throw new InvalidArgumentException("\"{$class}\" is not a DataObject subclass");
        }

        $this->dataObjectClass = $class;
        return $this;
    }
1232864
function &traitNamed($traitName)
    {
        $return = NULL;
        if (isset($this->_traits[$traitName])) {
            $return =& $this->__traits[$traitName];
        }

        return $return;
    }
1373425
public function hasTrait($trait): bool {
		if (!$trait instanceof PhpTrait) {
			$trait = new PhpTrait($trait);
		}
		$name = $trait->getName();
		return in_array($name, $this->traits);
	}
1196462
final public function whereInstanceOf(string $class)
    {
        if ($this->class === $class) {
            return $this;
        }

        if (!is_a($class, $this->class->getClassName(), true)) {
            throw InvalidArgumentException::format(
                'Invalid class supplied to %s: must be an a subclass of %s, %s given',
                __METHOD__, $this->class->getClassName(), $class
            );
        }

        $this->append(new InstanceOfCondition($class));
        
        if (!$this->isOrMode) {
            $this->class = $class::definition();
        }

        return $this;
    }
148117
public static function collectTraitsFromClassNode(ClassLike $classLikeNode, array &$traitAdaptations)
    {
        $traits = [];

        if (!empty($classLikeNode->stmts)) {
            foreach ($classLikeNode->stmts as $classLevelNode) {
                if ($classLevelNode instanceof TraitUse) {
                    foreach ($classLevelNode->traits as $classTraitName) {
                        if ($classTraitName instanceof FullyQualified) {
                            $traitName          = $classTraitName->toString();
                            $trait              = trait_exists($traitName, false)
                                ? new parent($traitName)
                                : new static($traitName);
                            $traits[$traitName] = $trait;
                        }
                    }
                    $traitAdaptations = $classLevelNode->adaptations;
                }
            }
        }

        return $traits;
    }
960941
public function setSetter($setter)
    {
        if (!is_bool($setter)) {
            throw new \InvalidArgumentException('The attribute setter on the class Attribute has to be boolean (' . gettype($setter) . ('object' === gettype($setter) ? ' ' . get_class($setter) : '') . ' given).');
        }

        $this->setter = $setter;

        return $this;
    }
81354
public function addTrait($trait) {
		if ($trait instanceof PhpTrait) {
			$name = $trait->getName();
			$qname = $trait->getQualifiedName();
			$namespace = $trait->getNamespace();

			if ($namespace != $this->getNamespace()) {
				$this->addUseStatement($qname);
			}
		} else {
			$name = $trait;
		}

		if (!in_array($name, $this->traits)) {
			$this->traits[] = $name;
		}

		return $this;
	}
1047760
protected function classUsesDeep($class)
    {
        $traits = [];

        // Get traits of all parent classes
        do {
            $traits = array_merge(class_uses($class), $traits);
        } while ($class = get_parent_class($class));

        // Get traits of all parent traits
        $traitsToSearch = $traits;
        while ( ! empty($traitsToSearch)) {
            $newTraits      = class_uses(array_pop($traitsToSearch));
            $traits         = array_merge($newTraits, $traits);
            $traitsToSearch = array_merge($newTraits, $traitsToSearch);
        };

        foreach ($traits as $trait => $same) {
            $traits = array_merge(class_uses($trait), $traits);
        }

        return array_unique($traits);
    }
365423
public function loadClass($class)
    {
        if (!isset($this->map[$class]) && $this->isNormalTrait($class)) {
            $path = $this->getFilePathFromClassPath($class);
            $dir = dirname($path);

            if (!is_dir($dir)) {
                if (file_exists($dir)) {
                    throw new \Exception($dir . ' is a file...');
                } else {
                    mkdir($dir, 0755, true);
                }
            }

            $result = file_put_contents(
                $path, sprintf(
                    "<?php\n\nnamespace %s;\n\ntrait %s\n{\n}\n", str_replace('/', '\\', dirname(str_replace('\\', '/', $class))), pathinfo($path)['filename']
                )
            );

            if ($result !== false || $result !== '') {
                ++$this->count;
                $this->output->writeln(sprintf('Generated trait %s', $path));
            }

            $this->map[$class] = $path;
        }

        if (isset($this->map[$class])) {
            include $this->map[$class];
        }
    }
649444
public function setProvider($class, $provider)
    {

        ltrim($class, '\\');

        if ($provider instanceof Provider) {
            $this->providers[$class] = $provider;
            return $this;
        }

        if (is_callable($provider)) {
            $this->providerFactories[$class] = $provider;
            return $this;
        }

        if (!is_string($provider)) {
            throw new InvalidArgumentException("Provider has to be callable, Provider or a class name.");
        }

        $this->providerFactories[$class] = function () use ($provider) {
            return $this->createObject($provider);
        };

        return $this;
    }
609670
protected function assignDateClass($class)
    {
        $refClass = new \ReflectionClass($class);

        if (!($refClass->getName() === 'DateTime' || $refClass->isSubclassOf('DateTime'))) {
            throw new \InvalidArgumentException("The class used to cast DATE and DATETIME values must be derived from DateTime.");
        }

        $this->dateClass = $class;
    }