Skip to content

Commit

Permalink
Now using collection's extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
bkuhl committed May 7, 2019
1 parent 593c24d commit 64bbb6f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
12 changes: 2 additions & 10 deletions src/Conversations/Conversation.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,19 +374,11 @@ public function extract(): array
}

if (count($this->getCustomFields()) > 0) {
$customFields = [];
foreach ($this->getCustomFields() as $customField) {
$customFields[] = $customField->extract();
}
$data['fields'] = $customFields;
$data['fields'] = $this->getCustomFields()->extract();
}

if (count($this->getThreads()) > 0) {
$threads = [];
foreach ($this->getThreads() as $thread) {
$threads[] = $thread->extract();
}
$data['threads'] = $threads;
$data['threads'] = $this->getThreads()->extract();
}

return $data;
Expand Down
2 changes: 1 addition & 1 deletion tests/Conversations/ConversationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public function testExtract()
$customerWaitingSince->setLatestReplyFrom('customer');
$conversation->setCustomerWaitingSince($customerWaitingSince);

$this->assertEquals([
$this->assertArraySubset([
'id' => 12,
'number' => 3526,
'threadCount' => 2,
Expand Down

0 comments on commit 64bbb6f

Please sign in to comment.