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

[Feature] Scoping #10

Closed
jstoone opened this issue Dec 14, 2017 · 3 comments
Closed

[Feature] Scoping #10

jstoone opened this issue Dec 14, 2017 · 3 comments

Comments

@jstoone
Copy link

jstoone commented Dec 14, 2017

About

I've been wanting to contribute to some of your projects, and then I stumbled upon this nifty little package.

So after playing around with the API for a while I had a few different names for the feaure:

  • scope()/unscope()/scopeGroup()
    I find this a relevant word since this feature will be used to group entries by a prefix to isolate them from other keys that might be "out of scope".
  • focus()/unfocus()/focusGroup()
    Nice because can be "eye" related word-wise, and focusGroup is funny pun
  • prefix()/endPrefix()/prefixGroup()
    Describes exactly what it does, but feels clunky since the naming reminds me of writing a Blade directive instead of a cache related operation.

Any of the three names I would be satisfied with, so feel free to say if you'd like focus() or prefix() instead of scope() or something entirely different.

Before writing this PR I stumbled upon #2, which describes exactly this feature but my take on it U feel like is a bit more expressive.

Feature suggestion:

Here is what I've written in the docs on my branch:

Playground

blink()->scope('acme-'); // Prefix all key-related interactions with "acme-"
blink()->once('number', 3); // Sets key "acme-number" equal to 3
blink()->forget('key'); // Forgets key "acme-key"
blink()->unscope(); // Remove scope

blink()->scopeGroup('acme-', function() { // Prefix all key-related interactions with "acme-"
    blink()->once('number', 3); // Sets key "acme-number" equal to 3
    blink()->forget('key'); // Forgets key "acme-key"
});

Method signatures

scope

/**
 * Add prefix to all key-related interactions.
 *
 * @param string $prefix
 *
 * @return $this
 */
 public function scope(string $prefix)

unscope

/**
 * Remove currently active scope.
 *
 * @return $this
 */
 public function unscope()

scopeGroup

/**
 * Add prefix to all key-related interactions, within closure.
 *
 * @return $this
 */
 public function scopeGroup(string $prefix, callable $callback)
@freekmurze
Copy link
Member

Hi,

thanks for your contribution, but I'm not going to pull it in.

The added functionality isn't need by most users and I'd like to keep the package a simple as it can be.

If you need this in your own projects, feel free to fork our code.

@jstoone
Copy link
Author

jstoone commented Dec 18, 2017

Thank you for your honesty.

Do you have a package in mind that you'd like help with or feel like needs some attention? Trying to get my contribution-game back on track. 👌

@freekmurze
Copy link
Member

I regularly tweet out good issues for those wanting to get started with contributing to open source. Keep an 👁 on that.

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