How to use getShortClassName method of namespace class

Best Atoum code snippet using namespace.getShortClassName

MakeEntity.php

Source:MakeEntity.php Github

copy

Full Screen

...421 $type = $this->askRelationType($io, $generatedEntityClass, $targetEntityClass);422 }423 $askFieldName = function (string $targetClass, string $defaultValue) use ($io) {424 return $io->ask(425 sprintf('New field name inside %s', Str::getShortClassName($targetClass)),426 $defaultValue,427 function ($name) use ($targetClass) {428 // it's still *possible* to create duplicate properties - by429 // trying to generate the same property 2 times during the430 // same make:entity run. property_exists() only knows about431 // properties that *originally* existed on this class.432 if (property_exists($targetClass, $name)) {433 throw new \InvalidArgumentException(sprintf('The "%s" class already has a "%s" property.', $targetClass, $name));434 }435 return Validator::validateDoctrineFieldName($name, $this->doctrineHelper->getRegistry());436 }437 );438 };439 $askIsNullable = function (string $propertyName, string $targetClass) use ($io) {440 return $io->confirm(sprintf(441 'Is the <comment>%s</comment>.<comment>%s</comment> property allowed to be null (nullable)?',442 Str::getShortClassName($targetClass),443 $propertyName444 ));445 };446 $askOrphanRemoval = function (string $owningClass, string $inverseClass) use ($io) {447 $io->text([448 'Do you want to activate <comment>orphanRemoval</comment> on your relationship?',449 sprintf(450 'A <comment>%s</comment> is "orphaned" when it is removed from its related <comment>%s</comment>.',451 Str::getShortClassName($owningClass),452 Str::getShortClassName($inverseClass)453 ),454 sprintf(455 'e.g. <comment>$%s->remove%s($%s)</comment>',456 Str::asLowerCamelCase(Str::getShortClassName($inverseClass)),457 Str::asCamelCase(Str::getShortClassName($owningClass)),458 Str::asLowerCamelCase(Str::getShortClassName($owningClass))459 ),460 '',461 sprintf(462 'NOTE: If a <comment>%s</comment> may *change* from one <comment>%s</comment> to another, answer "no".',463 Str::getShortClassName($owningClass),464 Str::getShortClassName($inverseClass)465 ),466 ]);467 return $io->confirm(sprintf('Do you want to automatically delete orphaned <comment>%s</comment> objects (orphanRemoval)?', $owningClass), false);468 };469 $askInverseSide = function (EntityRelation $relation) use ($io) {470 if ($this->isClassInVendor($relation->getInverseClass())) {471 $relation->setMapInverseRelation(false);472 return;473 }474 // recommend an inverse side, except for OneToOne, where it's inefficient475 $recommendMappingInverse = EntityRelation::ONE_TO_ONE !== $relation->getType();476 $getterMethodName = 'get'.Str::asCamelCase(Str::getShortClassName($relation->getOwningClass()));477 if (EntityRelation::ONE_TO_ONE !== $relation->getType()) {478 // pluralize!479 $getterMethodName = Str::singularCamelCaseToPluralCamelCase($getterMethodName);480 }481 $mapInverse = $io->confirm(482 sprintf(483 'Do you want to add a new property to <comment>%s</comment> so that you can access/update <comment>%s</comment> objects from it - e.g. <comment>$%s->%s()</comment>?',484 Str::getShortClassName($relation->getInverseClass()),485 Str::getShortClassName($relation->getOwningClass()),486 Str::asLowerCamelCase(Str::getShortClassName($relation->getInverseClass())),487 $getterMethodName488 ),489 $recommendMappingInverse490 );491 $relation->setMapInverseRelation($mapInverse);492 };493 switch ($type) {494 case EntityRelation::MANY_TO_ONE:495 $relation = new EntityRelation(496 EntityRelation::MANY_TO_ONE,497 $generatedEntityClass,498 $targetEntityClass499 );500 $relation->setOwningProperty($newFieldName);501 $relation->setIsNullable($askIsNullable(502 $relation->getOwningProperty(),503 $relation->getOwningClass()504 ));505 $askInverseSide($relation);506 if ($relation->getMapInverseRelation()) {507 $io->comment(sprintf(508 'A new property will also be added to the <comment>%s</comment> class so that you can access the related <comment>%s</comment> objects from it.',509 Str::getShortClassName($relation->getInverseClass()),510 Str::getShortClassName($relation->getOwningClass())511 ));512 $relation->setInverseProperty($askFieldName(513 $relation->getInverseClass(),514 Str::singularCamelCaseToPluralCamelCase(Str::getShortClassName($relation->getOwningClass()))515 ));516 // orphan removal only applies if the inverse relation is set517 if (!$relation->isNullable()) {518 $relation->setOrphanRemoval($askOrphanRemoval(519 $relation->getOwningClass(),520 $relation->getInverseClass()521 ));522 }523 }524 break;525 case EntityRelation::ONE_TO_MANY:526 // we *actually* create a ManyToOne, but populate it differently527 $relation = new EntityRelation(528 EntityRelation::MANY_TO_ONE,529 $targetEntityClass,530 $generatedEntityClass531 );532 $relation->setInverseProperty($newFieldName);533 $io->comment(sprintf(534 'A new property will also be added to the <comment>%s</comment> class so that you can access and set the related <comment>%s</comment> object from it.',535 Str::getShortClassName($relation->getOwningClass()),536 Str::getShortClassName($relation->getInverseClass())537 ));538 $relation->setOwningProperty($askFieldName(539 $relation->getOwningClass(),540 Str::asLowerCamelCase(Str::getShortClassName($relation->getInverseClass()))541 ));542 $relation->setIsNullable($askIsNullable(543 $relation->getOwningProperty(),544 $relation->getOwningClass()545 ));546 if (!$relation->isNullable()) {547 $relation->setOrphanRemoval($askOrphanRemoval(548 $relation->getOwningClass(),549 $relation->getInverseClass()550 ));551 }552 break;553 case EntityRelation::MANY_TO_MANY:554 $relation = new EntityRelation(555 EntityRelation::MANY_TO_MANY,556 $generatedEntityClass,557 $targetEntityClass558 );559 $relation->setOwningProperty($newFieldName);560 $askInverseSide($relation);561 if ($relation->getMapInverseRelation()) {562 $io->comment(sprintf(563 'A new property will also be added to the <comment>%s</comment> class so that you can access the related <comment>%s</comment> objects from it.',564 Str::getShortClassName($relation->getInverseClass()),565 Str::getShortClassName($relation->getOwningClass())566 ));567 $relation->setInverseProperty($askFieldName(568 $relation->getInverseClass(),569 Str::singularCamelCaseToPluralCamelCase(Str::getShortClassName($relation->getOwningClass()))570 ));571 }572 break;573 case EntityRelation::ONE_TO_ONE:574 $relation = new EntityRelation(575 EntityRelation::ONE_TO_ONE,576 $generatedEntityClass,577 $targetEntityClass578 );579 $relation->setOwningProperty($newFieldName);580 $relation->setIsNullable($askIsNullable(581 $relation->getOwningProperty(),582 $relation->getOwningClass()583 ));584 $askInverseSide($relation);585 if ($relation->getMapInverseRelation()) {586 $io->comment(sprintf(587 'A new property will also be added to the <comment>%s</comment> class so that you can access the related <comment>%s</comment> object from it.',588 Str::getShortClassName($relation->getInverseClass()),589 Str::getShortClassName($relation->getOwningClass())590 ));591 $relation->setInverseProperty($askFieldName(592 $relation->getInverseClass(),593 Str::asLowerCamelCase(Str::getShortClassName($relation->getOwningClass()))594 ));595 }596 break;597 default:598 throw new \InvalidArgumentException('Invalid type: '.$type);599 }600 return $relation;601 }602 private function askRelationType(ConsoleStyle $io, string $entityClass, string $targetEntityClass)603 {604 $io->writeln('What type of relationship is this?');605 $originalEntityShort = Str::getShortClassName($entityClass);606 $targetEntityShort = Str::getShortClassName($targetEntityClass);607 $rows = [];608 $rows[] = [609 EntityRelation::MANY_TO_ONE,610 sprintf("Each <comment>%s</comment> relates to (has) <info>one</info> <comment>%s</comment>.\nEach <comment>%s</comment> can relate to (can have) <info>many</info> <comment>%s</comment> objects", $originalEntityShort, $targetEntityShort, $targetEntityShort, $originalEntityShort),611 ];612 $rows[] = ['', ''];613 $rows[] = [614 EntityRelation::ONE_TO_MANY,615 sprintf("Each <comment>%s</comment> can relate to (can have) <info>many</info> <comment>%s</comment> objects.\nEach <comment>%s</comment> relates to (has) <info>one</info> <comment>%s</comment>", $originalEntityShort, $targetEntityShort, $targetEntityShort, $originalEntityShort),616 ];617 $rows[] = ['', ''];618 $rows[] = [619 EntityRelation::MANY_TO_MANY,620 sprintf("Each <comment>%s</comment> can relate to (can have) <info>many</info> <comment>%s</comment> objects.\nEach <comment>%s</comment> can also relate to (can also have) <info>many</info> <comment>%s</comment> objects", $originalEntityShort, $targetEntityShort, $targetEntityShort, $originalEntityShort),...

Full Screen

Full Screen

DddCode.php

Source:DddCode.php Github

copy

Full Screen

...83 * 获取基础类名84 * @param $className85 * @return string86 */87 public function getShortClassName($className)88 {89 if(empty($className))90 return "";91 $n=strripos($className,"\\");92 if($n===false)93 return $className;94 return substr($className,$n+1);95 }96 public function prepare()97 {98 // TODO: Implement prepare() method.99 $this->files=array();100 $fileConfigs=$this->getFileConfigs();101 $params=array(102 'context'=>$this->context,103 'entity'=>$this->entity,104 //"isAggregateRoot"=>$this->isAggregateRoot,105 "namespace"=>""106 );107 $this->entityNamespace=$this->namespacePrefix."\\".$this->context."\\Domain\\".$this->entityFolderName;108 $this->iRepositoryShortName=$this->getShortClassName($this->iRepository);109 $this->baseEntityShortName=$this->getShortClassName($this->baseEntity);110 $this->iAggregateRootShortName=$this->getShortClassName($this->iAggregateRoot);111 $this->baseRepositoryShortName=$this->getShortClassName($this->baseRepository);112 foreach ($fileConfigs as $file)113 {114 $params["namespace"]=$file["namespace"];115 $this->files[]=new CCodeFile(116 $file["path"],117 $this->render($file["template"],$params)118 );119 }120 }121 protected function getFileConfigs()122 {123 $basePath=Mod::getPathOfAlias($this->dddPath);124 $templatePath=$this->templatePath;125 return [...

Full Screen

Full Screen

getShortClassName

Using AI Code Generation

copy

Full Screen

1$object = new \Namespace\ClassName();2$object->getShortClassName();3$object = new \Namespace\ClassName();4$object->getShortClassName();5$object = new \Namespace\ClassName();6$object->getShortClassName();7$object = new \Namespace\ClassName();8$object->getShortClassName();9$object = new \Namespace\ClassName();10$object->getShortClassName();11$object = new \Namespace\ClassName();12$object->getShortClassName();13$object = new \Namespace\ClassName();14$object->getShortClassName();15$object = new \Namespace\ClassName();16$object->getShortClassName();17$object = new \Namespace\ClassName();18$object->getShortClassName();19$object = new \Namespace\ClassName();20$object->getShortClassName();21$object = new \Namespace\ClassName();22$object->getShortClassName();23$object = new \Namespace\ClassName();24$object->getShortClassName();25$object = new \Namespace\ClassName();26$object->getShortClassName();27$object = new \Namespace\ClassName();28$object->getShortClassName();

Full Screen

Full Screen

getShortClassName

Using AI Code Generation

copy

Full Screen

1use My\Full\Classname as Another;2use My\Full\NSname;3use My\Full\Classname as Another, My\Full\NSname;4use My\Full\{Classname, NSname as NS};5use My\Full\Classname;6use My\Full\NSname;7use My\Full\Classname, My\Full\NSname;8use My\Full\Classname;9use My\Full\NSname;

Full Screen

Full Screen

getShortClassName

Using AI Code Generation

copy

Full Screen

1use App\Classes\GetClassName;2echo GetClassName::getShortClassName();3use App\Classes\GetClassName;4echo GetClassName::getShortClassName();5use App\Classes\GetClassName as Name;6echo Name::getShortClassName();7use App\Classes\GetClassName as Name;8echo Name::getShortClassName();9use App\Classes\GetClassName as Name;10echo Name::getShortClassName();11use App\Classes\GetClassName as Name;12echo Name::getShortClassName();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful