Ejemplo n.º 1
0
 /**
  * (@inheritDoc}
  */
 public function createConditionStatement(Expr $input)
 {
     $conditionStatement = parent::createConditionStatement($input);
     foreach ($this->discriminants as $key => $values) {
         $issetCondition = new Expr\FuncCall(new Name('isset'), [new Arg(new Expr\PropertyFetch($input, sprintf("{'%s'}", $key)))]);
         $logicalOr = null;
         if ($values !== null) {
             foreach ($values as $value) {
                 if ($logicalOr === null) {
                     $logicalOr = new Expr\BinaryOp\Equal(new Expr\PropertyFetch($input, sprintf("{'%s'}", $key)), new Scalar\String_($value));
                 } else {
                     $logicalOr = new Expr\BinaryOp\LogicalOr($logicalOr, new Expr\BinaryOp\Equal(new Expr\PropertyFetch($input, sprintf("{'%s'}", $key)), new Scalar\String_($value)));
                 }
             }
         }
         if ($logicalOr !== null) {
             $conditionStatement = new Expr\BinaryOp\LogicalAnd($conditionStatement, new Expr\BinaryOp\LogicalAnd($issetCondition, $logicalOr));
         } else {
             $conditionStatement = new Expr\BinaryOp\LogicalAnd($conditionStatement, $issetCondition);
         }
     }
     return $conditionStatement;
 }