/** * Returns name of new method, which can be created from current through * {@link CodeGenerator::createNewMethodWithName}. * * @param string $newSubtype * * @return string Name of new method */ function makeNameForSubtype($newSubtype) { // ---- Source method has Accessor type switch ($this->subtype) { case Method::SUBTYPE_ASSERT: case Method::SUBTYPE_ASSERT_NOT: if (in_array($newSubtype, [Method::SUBTYPE_VERIFY, Method::SUBTYPE_VERIFY_NOT])) { return 'verify' . Helper::cutPrefix('assert', $this->name); } else { self::throwException("Incorrect subtype: some cases (may be) not handled."); } break; case Method::SUBTYPE_VERIFY: case Method::SUBTYPE_VERIFY_NOT: if (in_array($newSubtype, [Method::SUBTYPE_ASSERT, Method::SUBTYPE_ASSERT_NOT])) { return 'assert' . Helper::cutPrefix('verify', $this->name); } else { self::throwException("Incorrect subtype: some cases (may be) not handled."); } break; default: self::throwException("Incorrect subtype: some cases (may be) not handled."); } // todo implement and test other cases (other subtypes) }
/** * Returns "Fully Qualified Structural Element Name" (FQSEN) for specified property. * * @param string $propertyName Name of property (without class name). * Example: 'propertyName' or '$propertyName' * @param string $className Name of class, which contain specified property. Can contain namespaces. * By default (=''), it is assumed current class. * Example: 'ClassName', '\My\Space\MyClass' * * @return string Generated FQSEN * * @see http://www.phpdoc.org/docs/latest/glossary.html#term-fully-qualified-structural-element-name-fqsen * @see http://www.phpdoc.org/docs/latest/glossary.html#term-structural-element */ public static function fqsenForProperty($propertyName, $className = '') { $className = $className ? trim($className) . '::' : ''; $propertyName = '$' . Helper::cutPrefix('$', $propertyName); return $className . $propertyName; }