Skip to content

Commit

Permalink
Merge pull request #904 from bretto36/handle-null-values
Browse files Browse the repository at this point in the history
Handle null values
  • Loading branch information
calcinai authored Dec 19, 2023
2 parents 8ffec85 + 7669fad commit 9b14b5c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/XeroPHP/Remote/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function __construct(Application $application = null)
$this->_data = [];
$this->_associated_objects = [];
}

public static function make(Application $application = null)
{
return new static($application);
Expand Down Expand Up @@ -524,7 +524,9 @@ public function __set($property, $value)

protected function propertyUpdated($property, $value)
{
if (! isset($this->_data[$property]) || $this->_data[$property] !== $value) {
$currentValue = isset($this->_data[$property]) ? $this->_data[$property] : null;

if ($currentValue !== $value) {
//If this object can update itself, set its own dirty flag, otherwise, set its parent's.
if (count(array_intersect($this::getSupportedMethods(), [Request::METHOD_PUT, Request::METHOD_POST])) > 0) {
//Object can update itself
Expand Down
2 changes: 1 addition & 1 deletion tests/Application/ApplicationTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace XeroPHP\tests\Application;
namespace XeroPHP\Tests\Application;

use XeroPHP\Application;

Expand Down
2 changes: 1 addition & 1 deletion tests/HelpersTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace XeroPHP\tests;
namespace XeroPHP\Tests;

use XeroPHP\Helpers;

Expand Down
6 changes: 6 additions & 0 deletions tests/Remote/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ public function testPracticeManagerClientListIsReturned()
<Position />
</Contact>
</Contacts>
<Groups>
<Group>
<ID>783949</ID>
<Name>1 Geotechnical Limited</Name>
</Group>
</Groups>
</Client>
<Client>
<ID>697</ID>
Expand Down
2 changes: 1 addition & 1 deletion tests/Webhook/EventTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace XeroPHP\tests;
namespace XeroPHP\Tests\Webhook;

use XeroPHP\Webhook;
use XeroPHP\Application;
Expand Down
2 changes: 1 addition & 1 deletion tests/WebhookTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace XeroPHP\tests;
namespace XeroPHP\Tests;

use XeroPHP\Application;
use XeroPHP\Application\PrivateApplication;
Expand Down

0 comments on commit 9b14b5c

Please sign in to comment.