import { IFunctionCallArgument } from '@/application/Parser/Script/Compiler/Function/Call/Argument/IFunctionCallArgument' ; import { IFunctionCallArgumentCollection } from '@/application/Parser/Script/Compiler/Function/Call/Argument/IFunctionCallArgumentCollection' ; import { FunctionCallArgumentStub } from './FunctionCallArgumentStub' ; export class FunctionCallArgumentCollectionStub implements IFunctionCallArgumentCollection { private args = new Array < IFunctionCallArgument > ( ) ; public withArgument ( parameterName , argumentValue ) { const arg = new FunctionCallArgumentStub ( ) . withParameterName ( parameterName ) . withArgumentValue ( argumentValue ) ; this . addArgument ( arg ) ; return this ; } public withArguments ( args ) { for ( const [ name , value ] of Object . entries ( args ) ) { this . withArgument ( name , value ) ; } return this ; } public hasArgument ( parameterName ) { return this . args . some ( ( a ) => a . parameterName === parameterName ) ; } public addArgument ( argument ) { this . args . push ( argument ) ; } public getAllParameterNames ( ) { return this . args . map ( ( a ) => a . parameterName ) ; } public getArgument ( parameterName ) { const arg = this . args . find ( ( a ) => a . parameterName === parameterName ) ; if ( ! arg ) { throw new Error ( `no argument exists for parameter "${ parameterName }"` ) ; } return arg ; } }