Skip to content

Remove complexity #42

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 2 commits into from
Jul 10, 2020
Merged

Remove complexity #42

merged 2 commits into from
Jul 10, 2020

Conversation

JBlond
Copy link
Owner

@JBlond JBlond commented Jul 10, 2020

No description provided.

@JBlond JBlond merged commit 3a52371 into master Jul 10, 2020
@JBlond JBlond deleted the remove-complexity branch July 10, 2020 14:17
Copy link
Collaborator

@DigiLive DigiLive left a comment

Choose a reason for hiding this comment

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

I understand you want to reduce the complexity of SequenceMatcher, but imho this is the other way around.

Now you're extending a helper class with a base class, instead of the base class making use of a helper class. I think it's better to keep them separately and call the methods of the helper class when needed.

Since the methods in the SequenceMatcherHelper are independent you can declare them as static so you don't have to instantiate this class to make use of them.
When the methods are static, you can use them for any other class and the name SequenceMatcherHelper could be renamed to something more generic like Utils.

To use them in SequenceMatcher, you call them like Utils::methodName(arguments) (Assuming you've imported the correct namespaces).


SequenceMatcherHelper::arrayGetDefault() is redundant to the null coalesce operator.

$myArray = ['a', 'b', 'c'];
$aValue = SequenceMatcherHelper->arrayGetDefault($myArray, 1, 'Oops')

is the same as

$myArray = ['a', 'b', 'c'];
$aValue = $myArray[1] ?? 'Oops';

@JBlond
Copy link
Owner Author

JBlond commented Jul 11, 2020

Go for it. Make a change and open a PR. I'm happy to merge it.

JBlond added a commit that referenced this pull request Jul 11, 2020
JBlond added a commit that referenced this pull request Jul 11, 2020
DigiLive added a commit that referenced this pull request Jul 12, 2020
- Removed redundant method SequenceMatcherHelper::arrayGetDefault().
- Renamed SequenceMatcherHelper to more generic name DiffUtils.
- Changed calls to SequenceMatcherHelper::arrayGetDefault() into
  comparison with null coalesce operator.
- Moved helper class from renderer directory to Diff directory.
- Changed namespaces to reflect above changes.
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