Skip to content
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

Seed? #4

Closed
jbrooksuk opened this issue Jul 23, 2013 · 6 comments
Closed

Seed? #4

jbrooksuk opened this issue Jul 23, 2013 · 6 comments

Comments

@jbrooksuk
Copy link

What does the seed do? It's default is false but there is no way of overwriting it. It's not changed anywhere, so is it needed?

@selvinortiz
Copy link
Owner

The seed is not in use currently but it will be used for: match( $subject, $seed=null ) and replace( $replacement, $subject, $seed=null ) which will be implemented before 0.5 (stable)!

@jbrooksuk
Copy link
Author

What does it do exactly?

@selvinortiz
Copy link
Owner

The idea of seed is so that you can bypass the fluent expression builder and pass along your own expression/pattern string to be used in the match() and replace() methods.

So you could build your own pattern with the fluent interface as you'll do most of the time but there may be times when you may wish to pass along your own regular expression pattern, one case might be when running unit tests or testing output when a fluently built pattern isn't doing what you expect.

$flux = new namespace\Flux;
$flux->startOfLine()->anything()->endOfLine(); // Pattern /^(.*)$/
$flux->match( 'Anything but a new line!' ); // Uses the pattern built above
$flux->match( 'Anything but a new line!', '/^(.*)$/' ); // Uses the seed

@jbrooksuk
Copy link
Author

Oh I see. So you could validate the seeds regex using this.

selvinortiz added a commit that referenced this issue Jul 23, 2013
~- Fixes internal namespace conflict
- Changes namespace from Sortiz\Tools to SelvinOrtiz\Utils\Flux
- Adds composer support [Issue #3](#3)
- Adds the addSeed() and removeSeed() methods [Issue #4](#4)
- Adds the getInstance() static method
- Adds FluxUrlExample.php, FluxDateExample.php, and FluxPhoneExample.php
- Adds getSeed() to get the seed without forcing __toString on the object
- Adds getSegment() to extract a segment (capturing group) from the pattern
- Implements unit tests (60% coverage) [Issue #3](#3)
- Implements Full PSR-2 Compliance (Tabs over Spaces)
- Enables the seed on match() and replace() [Issue #4](#4)
- Removes example.php and defines them elsewhere
- Moves examples into /etc and defines one example per file
- Other small fixes and additions
@jbrooksuk
Copy link
Author

I've added this to my port now too.

@selvinortiz
Copy link
Owner

@jbrooksuk Awesome: )

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

No branches or pull requests

2 participants