/** * Factory that creates a PutRequest from a PutItem command * * @param AbstractCommand $command The command to create the request from * * @return PutRequest * * @throws InvalidArgumentException if the command is not a PutItem command */ public static function fromCommand(AbstractCommand $command) { if ($command->getName() !== 'PutItem') { throw new InvalidArgumentException(); } // Get relevant data for a PutRequest $table = $command->get('TableName'); $item = $command->get('Item'); // Return an instantiated PutRequest object return new PutRequest($item, $table); }
/** * Factory that creates a DeleteRequest from a DeleteItem command * * @param AbstractCommand $command The command to create the request from * * @return PutRequest * * @throws InvalidArgumentException if the command is not a DeleteItem command */ public static function fromCommand(AbstractCommand $command) { if ($command->getName() !== 'DeleteItem') { throw new InvalidArgumentException(); } // Get relevant data for a DeleteRequest $table = $command->get('TableName'); $key = $command->get('Key'); // Return an instantiated DeleteRequest object return new DeleteRequest($key, $table); }