Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.

Added process of quotes#3

Merged
michelphp merged 4 commits intomichelphp:mainfrom
jaumarar:process-quotes
Jul 4, 2021
Merged

Added process of quotes#3
michelphp merged 4 commits intomichelphp:mainfrom
jaumarar:process-quotes

Conversation

@jaumarar
Copy link
Copy Markdown
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
Copy Markdown
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

@michelphp
Copy link
Copy Markdown
Owner

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

@jaumarar
Copy link
Copy Markdown
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

@michelphp
Copy link
Copy Markdown
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
Copy Markdown
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;
  }
}

@michelphp
Copy link
Copy Markdown
Owner

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

@jaumarar
Copy link
Copy Markdown
Contributor Author

I think it should be finished now

Copy link
Copy Markdown
Owner

@michelphp michelphp 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

Comment thread src/Option.php Outdated
Comment thread src/Processor.php Outdated
@jaumarar
Copy link
Copy Markdown
Contributor Author

Hi @devcoder-xyz should I change anything more?

@michelphp
Copy link
Copy Markdown
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
Copy Markdown
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

@michelphp michelphp merged commit e61e0a0 into michelphp:main Jul 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants