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

Fixing notes typecast issue #34

Closed
wants to merge 3 commits into from
Closed

Conversation

mayankamencherla
Copy link
Contributor

[notes typecase] Hardcoding notes to be an array

src/Entity.php Outdated
if (in_array($data['entity'], $entities))
$entity = $data;
}
else
Copy link
Member

Choose a reason for hiding this comment

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

else if

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored

src/Entity.php Outdated
{
$entities = static::getDefinedEntitiesArray();

if (isset($data['entity']))
if (self::isNotes($key) === true)
Copy link
Member

Choose a reason for hiding this comment

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

make a generic isArrayableAttribute function.
Shift 'notes' to an array in the class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

src/Entity.php Outdated
@@ -138,7 +155,7 @@ public function fill($data)
{
if (is_array($v))
{
$entity = static::buildEntity($v);
$entity = static::buildEntity($key, $v);
Copy link
Member

Choose a reason for hiding this comment

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

create a separate function for filling a single key => value pair.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored. Added a helper for the associate array case as well.

Copy link
Member

@shashankkumar shashankkumar left a comment

Choose a reason for hiding this comment

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

.

Copy link
Contributor Author

@mayankamencherla mayankamencherla left a comment

Choose a reason for hiding this comment

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

src/Entity.php Outdated
{
$entities = static::getDefinedEntitiesArray();

if (isset($data['entity']))
if (self::isNotes($key) === true)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

src/Entity.php Outdated
if (in_array($data['entity'], $entities))
$entity = $data;
}
else
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored

src/Entity.php Outdated
@@ -138,7 +155,7 @@ public function fill($data)
{
if (is_array($v))
{
$entity = static::buildEntity($v);
$entity = static::buildEntity($key, $v);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored. Added a helper for the associate array case as well.

@mayankamencherla
Copy link
Contributor Author

@shashankkumar @73SL4 Kindly review.

@@ -67,15 +67,21 @@ protected function request($method, $relativeUrl, $data = null)
}
else
{
return static::buildEntity($response);
return static::buildEntity(null, $response);
Copy link
Contributor

Choose a reason for hiding this comment

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

@captn3m0 not sure if it's a good idea to pass null. Was thinking if we can make key as the second argument. What do you think?

@harman28
Copy link
Contributor

Will reopen if needed.

@harman28 harman28 closed this May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants