Skip to content

Added process of quotes #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 4, 2021
Merged

Added process of quotes #3

merged 4 commits into from
Jul 4, 2021

Conversation

jaumarar
Copy link
Contributor

If the .env file has a value wrapped in single or double quotes it will be parsed into a simple string:

.env file:
VARIABLE="value with double quotes"

Before:
$_ENV['VARIABLE] = "value with double quotes";

Now:
$_ENV['VARIABLE] = value with double quotes;

Also:

  • Separate the process of variables and the configuration to other classes
  • Added test to this feature
  • Modified README

@jaumarar
Copy link
Contributor Author

jaumarar commented Mar 7, 2021

Hi! @devcoder-xyz,
had you have time to look at this propossal? My intention is to use this package in several projects and it would be nice to add features like this and the process of numbers, for example.

I'm glad to help and hear your opinion about this so if there is something that you are not comfortable adding there will be no problems. Greetings

@phpdevcommunity
Copy link
Owner

@jaumarar Thanks for your help, had you read my comments ? i submit review if you can fix it

@jaumarar
Copy link
Contributor Author

Hi @devcoder-xyz i'm not seeing any reviews or comments in the mr nor other branches.

can you link me here those comments? maybe are marked as draft or the reviews has not been started

@phpdevcommunity
Copy link
Owner

ok no problem 👍
Processor.php : Can you create a class unique for one resolve ?
in the Processor class, create a collection of Resolver and each resolver resolves a value

its possible ?

@jaumarar
Copy link
Contributor Author

jaumarar commented Mar 13, 2021

Sure, something like?

Processor.php
Processor
  | BooleanProcessor.php
  | QuotedProcessor.php

Where Processor.php

class Processor
{
  execute($value)
  {
    foreach ([BooleanProcessor::class, QuotedProcessor::class] as $processorClass) {
      $processor = new $processorClass($value);

      if ($processor->canBeExecuted()) {
        return $processor->execute();
      }
    }

    return $value;
  }
}

@phpdevcommunity
Copy link
Owner

yes like this but Processor's Name willl be added in DotEnv (constructor)

@jaumarar
Copy link
Contributor Author

I think it should be finished now

Copy link
Owner

@phpdevcommunity phpdevcommunity left a comment

Choose a reason for hiding this comment

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

src/DotEnv.php

you forget "?" after array type,
Default value is NULL its ok but if $processors is null set Processors(null) , There will be a fatal error

src/Processor/QuotedProcessor.php

isWrappedByChar can be a private method

thank you very much @jaumarar it's perfect

@jaumarar
Copy link
Contributor Author

Hi @devcoder-xyz should I change anything more?

@phpdevcommunity
Copy link
Owner

Yes please , you not see my comment ?

src/DotEnv.php

you forget "?" after array type,
Default value is NULL its ok but if $processors is null set Processors(null) , There will be a fatal error
src/Processor/QuotedProcessor.php

isWrappedByChar can be a private method

thank you very much @jaumarar it's perfect

@jaumarar
Copy link
Contributor Author

Hi @devcoder-xyz I was away for a long time..

I hace added a test to proof that that DotEnv::setProcessors() should be safe to pass anything invalid since it filters invalid values, let me know if you need anything more

@phpdevcommunity phpdevcommunity merged commit e61e0a0 into phpdevcommunity:main Jul 4, 2021
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