Conversation
… method implemented
| protected InputValidator $validator, | ||
| protected Fast $newFast | ||
| ) | ||
| { |
There was a problem hiding this comment.
According to psr, this should be on the line above like ) {
| */ | ||
| protected function getStartDate() | ||
| { | ||
| $this->output->writeYellow('Enter Start Date of Fast format:(Y-m-d H:i:s) => (2020-10-10 20:00:00)'); |
There was a problem hiding this comment.
I would suggest refactoring like this to make it more usable
$this->output->write('text', COLORS.YELLOW)
or
$this->output->write('text', options)
| $this->printFastTypes(); | ||
| $userInput = $this->input->getInput(); | ||
|
|
||
| while (!key_exists($userInput, $this->fastTypes)) { |
There was a problem hiding this comment.
You could also use isset($this->fastTypes[$userInput]) to shorten it
| use App\Console\{InputConsole, InputValidator, OutputConsole}; | ||
| use App\Interface\{BaseCommandInterface , FileManagerInterface}; | ||
| use App\Model\Fast; | ||
|
|
There was a problem hiding this comment.
No need of that much empty lines :)
|
|
||
| ]; | ||
|
|
||
| public function __construct( |
There was a problem hiding this comment.
Why do you need a constructor with empty body ?
There was a problem hiding this comment.
The body of the constructor is empty because the properties of the class are defined in the entry parameters. According to PHP 8.0 documentation you can declare class properties in the constructor with no need of assigning them in the body PHP does it for you. Am i wrong ? Here is where i read that https://stitcher.io/blog/constructor-promotion-in-php-8
App/Commands/EndCommand.php
Outdated
|
|
||
| class EndCommand extends BaseCommandController implements BaseCommandInterface | ||
| { | ||
|
|
There was a problem hiding this comment.
Its beter to avoid to have so much empty lines :)
| public function print(): string | ||
| { | ||
| return " | ||
| -------------------------------------- |
There was a problem hiding this comment.
This one also should be formatted :)
There was a problem hiding this comment.
I don't understand can you please specify. This is written this way because this is the exact format i want to be printed into the console.
App/Store/StoreManager.php
Outdated
| class StoreManager implements FileManagerInterface | ||
| { | ||
|
|
||
| protected string $file = "./store.json"; |
There was a problem hiding this comment.
It would be good if you are getting the file name from a .env file so you can change it whenever you want
App/Store/StoreManager.php
Outdated
| { | ||
| $today = new DateTime('NOW'); | ||
| $fastArray = []; | ||
| $storeFasts = json_decode( |
There was a problem hiding this comment.
Maybe create a class helpers for methods like this
so you can do
Json::decode()
Json::encode()
App/Store/StoreManager.php
Outdated
| */ | ||
| public function write($fasts) | ||
| { | ||
| file_put_contents($this->file, json_encode($fasts)); |
There was a problem hiding this comment.
You can also create a helper class to work with files so you can use those instead of generic pHP functions
store.json
Outdated
| @@ -0,0 +1 @@ | |||
| [{"status":0,"start":"2022-10-11 10:00:00","end":"2022-10-11 22:00:00","type":12,"elapsed_time":""}] No newline at end of file | |||
There was a problem hiding this comment.
This should probably be in gitignore and be created on the fly
Merge with develop