Skip to content

Develop#1

Open
ziberiDev wants to merge 25 commits intomainfrom
develop
Open

Develop#1
ziberiDev wants to merge 25 commits intomainfrom
develop

Conversation

@ziberiDev
Copy link
Owner

Merge with develop

protected InputValidator $validator,
protected Fast $newFast
)
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need of that much empty lines :)


];

public function __construct(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need a constructor with empty body ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


class EndCommand extends BaseCommandController implements BaseCommandInterface
{

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its beter to avoid to have so much empty lines :)

public function print(): string
{
return "
--------------------------------------
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one also should be formatted :)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

class StoreManager implements FileManagerInterface
{

protected string $file = "./store.json";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good if you are getting the file name from a .env file so you can change it whenever you want

{
$today = new DateTime('NOW');
$fastArray = [];
$storeFasts = json_decode(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe create a class helpers for methods like this
so you can do

Json::decode()
Json::encode()

*/
public function write($fasts)
{
file_put_contents($this->file, json_encode($fasts));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be in gitignore and be created on the fly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants