Ich möchte diese Funktion kurz. Ich habe auch einen kleinen Teil davon veröffentlicht, aber es ist jedes Mal das gleiche Prinzip:Shortcut ähnliche Befehle in PHP-Funktion
if(in_array($infinitiveVerb,
IrregularExceptionGroup::$name_in_lowercase)) {
$exceptionmodel = ExceptionModel::NAME_IN_UPPERCASE;
}
PHP-Funktion
function finding_exception_model(InfinitiveVerb $infinitiveVerb)
{
$exceptionmodel = ExceptionModel::NO_EXCEPTIONS;
if (in_array($infinitiveVerb, IrregularExceptionGroup::$aller)) {
$exceptionmodel = ExceptionModel::ALLER;
}
if (in_array($infinitiveVerb, IrregularExceptionGroup::$avoir_irr)) {
$exceptionmodel = ExceptionModel::AVOIR_IRR;
}
if (in_array($infinitiveVerb, IrregularExceptionGroup::$etre_irr)) {
$exceptionmodel = ExceptionModel::ETRE_IRR;
}
return new ExceptionModel($exceptionmodel);
}
ExceptionModel.php
class ExceptionModel extends Enum
{
const NO_EXCEPTIONS = 'no exceptions';
const ALLER = 'aller';
const AVOIR_IRR = 'avoir_irr';
const ETRE_IRR = 'etre_irr';
}
Wie Ist das möglich?
was genau ist die Frage? Ich habe keine Ahnung, was du fragst. – DevDonkey
Sie wissen, dass Sie die Variable in jeder if-Anweisung überschreiben, wenn sie eingegeben wird? Sind Sie sicher, dass Sie nicht möchten, wenn/elseif? – Rizier123
Ich möchte nicht ähnliche Bedingungen haben, weil sie sehr ähnlich sind. Wie man eine if-Bedingung für alle 'ExceptionModels' verwendet. – Grischa