-
Notifications
You must be signed in to change notification settings - Fork 140
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
Allow external operator use #16
Conversation
I've been thinking a bit about extensibility, but this isn't exactly the direction I'd take. One question first: are you using PHP 5.4+? (The way I word my suggestion depends on this answer :)) |
For my personal use, I surely answer yes but unfortunately, I also have a job where we always use PHP 5.3 :) |
I personally love this pull request and find it so useful. Nowadays there's no way to easily add operators without forking the project, and that's a real problem. |
@tophsic I've cherry-picked this change into a branch made from the current develop...feature/external-operators Aside from updating it to match the new class structure and constructor arguments, the one big change I made is that operator namespaces are registered on the As a test, I removed all the operator methods from https://gist.github.com/bobthecow/30e7b9c83897a5f3f30d Note that for this test I had to make a bunch of operator class aliases so that methods would work as expected ( I'm not completely sold on this implementation, but I think it might be workable. @jwage @ludicruz @devantoine what do you think? |
And a bonus thing: With a fairly simple change: diff --git a/src/Ruler/Operator/Brevity/Eq.php b/src/Ruler/Operator/Brevity/Eq.php
new file mode 100644
index 0000000..b1aba02
--- /dev/null
+++ b/src/Ruler/Operator/Brevity/Eq.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace Ruler\Operator\Brevity;
+
+use Ruler\Operator\EqualTo;
+
+class Eq extends EqualTo
+{
+}
diff --git a/src/Ruler/Operator/Brevity/Gt.php b/src/Ruler/Operator/Brevity/Gt.php
new file mode 100644
index 0000000..69981c7
--- /dev/null
+++ b/src/Ruler/Operator/Brevity/Gt.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace Ruler\Operator\Brevity;
+
+use Ruler\Operator\GreaterThan;
+
+class Gt extends GreaterThan
+{
+}
diff --git a/src/Ruler/Operator/Brevity/Gte.php b/src/Ruler/Operator/Brevity/Gte.php
new file mode 100644
index 0000000..dadba9f
--- /dev/null
+++ b/src/Ruler/Operator/Brevity/Gte.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace Ruler\Operator\Brevity;
+
+use Ruler\Operator\GreaterThanOrEqualTo;
+
+class Gte extends GreaterThanOrEqualTo
+{
+}
diff --git a/src/Ruler/Operator/Brevity/Lt.php b/src/Ruler/Operator/Brevity/Lt.php
new file mode 100644
index 0000000..aaa02e2
--- /dev/null
+++ b/src/Ruler/Operator/Brevity/Lt.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace Ruler\Operator\Brevity;
+
+use Ruler\Operator\LessThan;
+
+class Lt extends LessThan
+{
+}
diff --git a/src/Ruler/Operator/Brevity/Lte.php b/src/Ruler/Operator/Brevity/Lte.php
new file mode 100644
index 0000000..74e0d41
--- /dev/null
+++ b/src/Ruler/Operator/Brevity/Lte.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace Ruler\Operator\Brevity;
+
+use Ruler\Operator\LessThanOrEqualTo;
+
+class Lte extends LessThanOrEqualTo
+{
+}
diff --git a/src/Ruler/Operator/Brevity/Neq.php b/src/Ruler/Operator/Brevity/Neq.php
new file mode 100644
index 0000000..a1d937d
--- /dev/null
+++ b/src/Ruler/Operator/Brevity/Neq.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace Ruler\Operator\Brevity;
+
+use Ruler\Operator\NotEqualTo;
+
+class Neq extends NotEqualTo
+{
+} |
Closing this in favor of #30 |
Allowing to implement specific operators using Ruler API and store them in a specific namespace. Implementation can surely be improved.
Maybe I didn't undersand well how to bring my porcelain :)