Scenarios
1. Reading and processing data from a JSON file
These scenarios assume you have made a class “MyClass” which extends from Service. You may use the default Service in many cases by simply creating new Encoding/Decoding classes. (See ./approach/Service/CSV.php for a simple example)
In this scenario, we will read data from a JSON file, process it, and then save the output in another JSON file.
- Create a JSON file named “input.json” with the following content:
- Create a new Service instance with the following parameters:
- Define the
Process
method to double the value of each item in the data array
- Run the service. The result will be saved in a file named “output.json”.
2. Fetching data from an API and saving it as a CSV file
In this scenario, we will fetch data from an API, process it, and then save the output as a CSV file.
- Create a new Service instance with the following parameters:
- Define the
Process
method to double the value of each item in the data array
- Run the service. The result will be saved in a file named “output.csv”.
3. Receiving input from the command line and printing the output
In this scenario, we will receive input from the command line, process it, and then print the output.
- Create a new Service instance with the following parameters:
- Define the
Process
method to double the value of each item in the data array
- Run the service. The user will be prompted to enter input text in the command line, and the reversed text will be printed as output.