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

Add endpoint for getting item properties #53

Merged
merged 1 commit into from Dec 11, 2017

Conversation

foglcz
Copy link
Contributor

@foglcz foglcz commented Dec 4, 2017

Depends on matej's deploy of RAD-720

Depends on #46 - before merging, change base of PR

Implements GET /item-properties

@foglcz foglcz requested a review from OndraM December 4, 2017 17:22
Copy link
Member

@OndraM OndraM left a comment

Choose a reason for hiding this comment

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

Could you also add some exmaple usage to readme? (But keep it short - as this is just an "auxiliary" endpoint used mainly for debugging, and not a main feature :) ).

Also something is missing code coverage according to coveralls, could you have a look, please?

@@ -7,10 +7,8 @@
use Lmc\Matej\Model\Command\ItemPropertySetup;
use Lmc\Matej\Model\Request;

class ItemPropertiesSetupRequestBuilder extends AbstractRequestBuilder
class ItemPropertiesModifierRequestBuilder extends ItemPropertiesGetterRequestBuilder
Copy link
Member

Choose a reason for hiding this comment

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

My preference is to keep this name as is - its meaning is already IMHO clear and distinctive from the GET version, and this adds no extra value - maybe even is confusing, because you actually cannot modify (like change data type) item properties once they are created in the database. So the the ItemPropertiesSetupRequestBuilder is for me ok. What do you think?

use Fig\Http\Message\RequestMethodInterface;
use Lmc\Matej\Model\Request;

class ItemPropertiesGetterRequestBuilder extends AbstractRequestBuilder
Copy link
Member

Choose a reason for hiding this comment

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

Its a builder, which build request to get item properties (Its not building "getter request"), so why not just ItemPropertiesGetRequestBuilder? (But only if the other one is kept as ItemPropertiesSetupRequestBuilder)

array $properties
): ItemPropertiesModifierRequestBuilder {
foreach ($properties as $name => $definition) {
$property = forward_static_call([Command\ItemPropertySetup::class, $definition[0]], $name);
Copy link
Member

Choose a reason for hiding this comment

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

ItemPropertySetup::$definition[0]($name) :)?

Copy link
Contributor Author

@foglcz foglcz Dec 11, 2017

Choose a reason for hiding this comment

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

That wouldn't work as PHP would think that $definition is a static array on ItemPropertySetup class.

Would have to be ItemPropertySetup::{$definition[0]}($name) which I found pretty ugly :|

}

/**
* @return array[string, array[string, mixed]]
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure there is any common PHP standard of defining internal array structure (and PHPStorm don't understand this, no?) , so we may just stick with standardized array[]...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's true that phpstorm doesn't understand this notation, but PHPStan does :)

Copy link
Member

@OndraM OndraM Dec 11, 2017

Choose a reason for hiding this comment

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

Is it documented somewhere in PHPStan? I couldn't find it...

@@ -7,10 +7,8 @@
use Lmc\Matej\Model\Command\ItemPropertySetup;
use Lmc\Matej\Model\Request;

class ItemPropertiesSetupRequestBuilder extends AbstractRequestBuilder
class ItemPropertiesModifierRequestBuilder extends ItemPropertiesGetterRequestBuilder
Copy link
Member

Choose a reason for hiding this comment

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

If the inheritance is there just because of the endpoint path, I'd not introduce it at all and rather have the endpoint path copied on two places. "Setup request builder" is from my POV not specific version of "Get request builder". It would only make sense IMHO to have AbstractItemPropertiesRequestBuilder with two childs, but would be a bit overengineered :).

@foglcz foglcz force-pushed the feature/get-item-properties-setup branch from 28b6d5a to 96c7edd Compare December 5, 2017 15:37
@foglcz foglcz changed the base branch from master to feature/integration-tests December 5, 2017 15:38
use Fig\Http\Message\RequestMethodInterface;
use Lmc\Matej\Model\Request;

class ItemPropertiesGetRequestBuilder extends AbstractRequestBuilder
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add also simple unit test for this builder? (See other unit tests for builders).

CHANGELOG.md Outdated
@@ -5,6 +5,7 @@
<!-- There is always Unreleased section on the top. Subsections (Added, Changed, Fixed, Removed) should be added as needed. -->

## Unreleased
- Endpoint `$matej->getItemProperties()` that returns all defined item properties
Copy link
Member

Choose a reason for hiding this comment

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

### Added
- Endpoint to get all defined item properties in the Matej database (`$matej->request()->getItemProperties()`).

@OndraM OndraM changed the base branch from feature/integration-tests to master December 7, 2017 13:14
@OndraM OndraM changed the title Add endpoint for getting item properties (do not merge) Add endpoint for getting item properties Dec 7, 2017
@OndraM OndraM force-pushed the feature/get-item-properties-setup branch from e5aa9f9 to 6c15fb2 Compare December 7, 2017 13:16
@@ -7,10 +7,8 @@
use Lmc\Matej\Model\Command\ItemPropertySetup;
use Lmc\Matej\Model\Request;

class ItemPropertiesSetupRequestBuilder extends AbstractRequestBuilder
class ItemPropertiesSetupRequestBuilder extends ItemPropertiesGetRequestBuilder
Copy link
Member

@OndraM OndraM Dec 11, 2017

Choose a reason for hiding this comment

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

What do you think about this? (The comment got "outdated" by github after the rebase...)

If the inheritance is there just because of the endpoint path, I'd not introduce it at all and rather have the endpoint path copied on two places. "Setup request builder" is from my POV not specific version of "Get request builder". It would only make sense IMHO to have AbstractItemPropertiesRequestBuilder with two childs, but would be a bit overengineered :).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a very good point; I was thinking from the perspective of REST endpoints - and not from the perspective of RequestBuilders.

Will update code in a sec.

Copy link
Member

@OndraM OndraM left a comment

Choose a reason for hiding this comment

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

If you could please rebase the PR (to get rid of the fixup commits) and we can merge it then 🎉

@foglcz foglcz force-pushed the feature/get-item-properties-setup branch from 2504f2e to d9db672 Compare December 11, 2017 13:48
@OndraM OndraM merged commit 4e4b3af into master Dec 11, 2017
@foglcz foglcz deleted the feature/get-item-properties-setup branch December 11, 2017 13:56
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