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/callback models #67 #69

Merged
merged 35 commits into from
Nov 15, 2017
Merged

Feature/callback models #67 #69

merged 35 commits into from
Nov 15, 2017

Conversation

OGKevin
Copy link
Contributor

@OGKevin OGKevin commented Nov 10, 2017

Closes #67
Closes #70

@OGKevin OGKevin added this to the 0.12.3 milestone Nov 10, 2017
@OGKevin OGKevin self-assigned this Nov 10, 2017
Copy link
Contributor

@dnl-blkv dnl-blkv left a comment

Choose a reason for hiding this comment

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

A few comments :)

@@ -0,0 +1,202 @@
{"NotificationUrl": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please prettify this json and the others with some prettifier :)

*
* @return BunqModel
*/
public static function fromJsonToModel(string $json): BunqModel
Copy link
Contributor

Choose a reason for hiding this comment

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

let's say createFromJsonString

@@ -0,0 +1,282 @@
<?php

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this newline :P

const ASSERT_JSON_DECODE_ERROR = 'Might be that the JSON file is not a valid json.';
const ASSERT_OBJECT_IS_NULL_ERROR = 'Object seems to be null.';


Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this newline :D

*/
const ASSERT_SHOULD_NOT_REACH_THIS_CODE_ERROR = 'Something super weird just happen';
const ASSERT_JSON_DECODE_ERROR = 'Might be that the JSON file is not a valid json.';
const ASSERT_OBJECT_IS_NULL_ERROR = 'Object seems to be null.';
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably would like to be a bit more formal with these :D

*/
private function executeTest(string $fileName, string $className, string $getterName)
{
$jsonString = FileUtil::getFileContents($fileName);
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's go for jsonExpected or jsonExpectedString

private function getNotificationUrlFromJson(string $jsonString): NotificationUrl
{
$json = json_decode($jsonString, true);
static::assertNotNull($json, self::ASSERT_JSON_DECODE_ERROR);
Copy link
Contributor

Choose a reason for hiding this comment

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

Assertions like personal space (unless they stick to other assertions) or get anxious otherwise. Please surround this one with newlines :D

}

/**
* @param array $json
Copy link
Contributor

Choose a reason for hiding this comment

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

array of what? :P

}

/**
* @param array $json
Copy link
Contributor

Choose a reason for hiding this comment

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

array of what? :P

*
* @return string
*/
private function getNotificationObjectAsString(array $json)
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps, getNotificationObjectJsonString ? :)

@OGKevin
Copy link
Contributor Author

OGKevin commented Nov 12, 2017

@dnl-blkv all yours 👀

Copy link
Contributor

@dnl-blkv dnl-blkv left a comment

Choose a reason for hiding this comment

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

A few comments in the code + one general:
I see you have replaced in quite some places resource folder name to Resource. But did you also rename the folder itself?

Diff shows some additions, such as tests/resource/NotificationUrlJsons/BunqMeTab.json, where resource is not capitalised...

tests/README.md Outdated
@@ -32,7 +32,7 @@ are also tested :thumbs_up:.
## Configuration

To run the tests you must first setup the test configuration JSON. The example
of a configuration file is located at [`tests/resource/config.example.json`](./resource/config.example.json).
of a configuration file is located at [`tests/Resource/config.example.json`](Resource/config.example.json).
Copy link
Contributor

Choose a reason for hiding this comment

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

./ was OK :D

}
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add terminating newline

}
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add terminating newline

/**
* Getter string constants
*/
const GET_PAYMENT = 'getPayment';
Copy link
Contributor

Choose a reason for hiding this comment

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

Let us prefix these with GETTER_, e.g. GETTER_PAYMENT

@OGKevin
Copy link
Contributor Author

OGKevin commented Nov 14, 2017

@dnl-blkv yes the Folder has been renamed to Resource 🤔. At least thats what it says on my local machine might be that something went wrong with git 🤔.

Copy link
Contributor

@dnl-blkv dnl-blkv left a comment

Choose a reason for hiding this comment

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

A few more comments...

/**
* Assertion errors.
*/
const ASSERT_SHOULD_NOT_REACH_THIS_CODE_ERROR = 'Congratulations you\'ve reached unreachable code.';
Copy link
Contributor

Choose a reason for hiding this comment

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

Please prefix all the error constants with ERROR_ (instead of _ERROR suffix); Also please put them to the top of the file (since this is how we do it across the SDKs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, the text of this assertion doesn't seem to be very descriptive :(

return $model;
}

throw new BunqException(self::ASSERT_SHOULD_NOT_REACH_THIS_CODE_ERROR);
Copy link
Contributor

Choose a reason for hiding this comment

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

The name of the error constant (just as its content) does not reflect the actual cause of the error. Please adjust it!

* @param BunqModel $model
*
* @return NotificationUrl
* @throws BunqException
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add the explanation of when the error is thrown:
@throws BunqException when {something}

{
static::assertArrayHasKey(self::KEY_NOTIFICATION_URL_MODEL, $json);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please rearrange methods in this class in accordance with the step-down rule (depth-first order).

const FIELD_PAYMENT = 'payment';
const FIELD_SCHEDULE = 'schedule';

/**
* Object type.
*/
const OBJECT_TYPE = 'SchedulePayment';
Copy link
Contributor

Choose a reason for hiding this comment

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

Please include the fix for the OBJECT_TYPE's of scheduled objects.

Copy link
Contributor

@dnl-blkv dnl-blkv left a comment

Choose a reason for hiding this comment

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

Looks good!

@dnl-blkv dnl-blkv merged commit e7c1123 into develop Nov 15, 2017
@dnl-blkv
Copy link
Contributor

@andrederoos

@dnl-blkv dnl-blkv deleted the feature/callback_models_#67 branch November 15, 2017 08: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