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

Ability to define custom Graph class in TypeMapper. closes #380 #381

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

madbob
Copy link

@madbob madbob commented Apr 5, 2021

Also added related tests.

Copy link
Contributor

@k00ni k00ni left a comment

Choose a reason for hiding this comment

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

Useful addition.

lib/Sparql/Client.php Outdated Show resolved Hide resolved
lib/TypeMapper.php Outdated Show resolved Hide resolved
}

$ancestors = class_parents($class);
if (($class != 'EasyRdf\Graph') && (empty($ancestors) || !in_array('EasyRdf\Graph', $ancestors))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would use 0 == count($ancestors) instead of empty($ancestors) here. It improves code understanding. Never tried it with arrays but doc says:

A variable is considered empty if it does not exist or if its value equals false.

Copy link
Author

Choose a reason for hiding this comment

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

Here I've copied the implementation of TypeMapper::setDefaultResourceClass().
Perhaps count() == 0 can be used (but not in Yoda notation, not used anywhere in the whole code).
And, even better: the whole block of conditions can be moved in a dedicated private function, to be reused.

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.

None yet

2 participants