|
@ -22,7 +22,9 @@ class OperatorBinary extends TokenBinary implements ICloudformationNative |
|
|
public const OPERATORS = [ |
|
|
public const OPERATORS = [ |
|
|
'and', |
|
|
'and', |
|
|
'or', |
|
|
'or', |
|
|
'eq' |
|
|
'eq', |
|
|
|
|
|
'concat', |
|
|
|
|
|
'select' |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -147,8 +149,32 @@ class OperatorBinary extends TokenBinary implements ICloudformationNative |
|
|
|
|
|
|
|
|
return null; |
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
case 'concat': |
|
|
|
|
|
if (is_scalar($value1) && is_scalar($value2)) |
|
|
|
|
|
{ |
|
|
|
|
|
return $value2.$value1; |
|
|
|
|
|
} |
|
|
|
|
|
elseif ($value1 instanceof Parameter && is_scalar($value2) && empty($value2)) |
|
|
|
|
|
{ |
|
|
|
|
|
return $value1; |
|
|
|
|
|
} |
|
|
|
|
|
elseif ($value2 instanceof Parameter && is_scalar($value1) && empty($value1)) |
|
|
|
|
|
{ |
|
|
|
|
|
return $value2; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
case 'select': |
|
|
|
|
|
if (is_scalar($value1) && is_array($value2)) |
|
|
|
|
|
{ |
|
|
|
|
|
return $value2[$value1]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
default: |
|
|
default: |
|
|
throw new \Exception('Missing implementation for unary operator: '.$this->getOperator()); |
|
|
throw new \Exception('Missing implementation for binary operator: '.$this->getOperator()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -174,8 +200,12 @@ class OperatorBinary extends TokenBinary implements ICloudformationNative |
|
|
return ['Fn::Or' => [$value1, $value2]]; |
|
|
return ['Fn::Or' => [$value1, $value2]]; |
|
|
case 'eq': |
|
|
case 'eq': |
|
|
return ['Fn::Equals' => [$value1, $value2]]; |
|
|
return ['Fn::Equals' => [$value1, $value2]]; |
|
|
|
|
|
case 'concat': |
|
|
|
|
|
return ['Fn::Join' => ['', [$value2, $value1]]]; |
|
|
|
|
|
case 'select': |
|
|
|
|
|
return ['Fn::Select' => [$value1, $value2]]; |
|
|
default: |
|
|
default: |
|
|
throw new \Exception('Missing implementation for unary operator: '.$this->getOperator()); |
|
|
throw new \Exception('Operator cannot be applied to parameters: '.$this->getOperator()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|