/** * If type is callable object or in namespace then can render type hinting in setter * @todo refactor * * @return boolean */ public function canAddTypeHinting() { if (class_exists($this->getProperty()->getTypeName())) { return true; } return Tools::isNamespaceValid($this->getProperty()->getType(), false); }
/** * Append \Test\ part to namespace * * @param string $namespace * @return string * @throws Exception */ protected function appendTestDirectory($namespace) { if (false == Tools::isNamespaceValid($namespace)) { throw new Exception(sprintf("Invalid namespace: %s", $namespace)); } $namespace = Tools::removeBackslashPrefixFromNamespace($namespace); $namespaceParts = explode("\\", $namespace); $firstParts = array_slice($namespaceParts, 0, 1); $secondParts = array_slice($namespaceParts, 1, count($namespaceParts) - 1); $newNamespaceParts = []; $newNamespaceParts = array_merge($newNamespaceParts, $firstParts); $newNamespaceParts[] = "Tests"; $newNamespaceParts = array_merge($newNamespaceParts, $secondParts); return "\\" . implode("\\", $newNamespaceParts); }
/** * @Assert\IsTrue(message = "Invalid interface namespace, check yaml schema! eg. \AppBundle\Location\Entity") * @return boolean */ public function isValidNamespace() { return Tools::isNamespaceValid($this->getNamespace()); }
/** * @dataProvider dataForMethodIsNamespaceValidFirstBackslashNotMandatory */ public function testIsNamespaceValidFirstBackslashNotMandatory($namespace) { $this->assertTrue(Tools::isNamespaceValid($namespace, false)); }