1 | <?php |
||
2 | /** |
||
3 | * Transcript |
||
4 | * |
||
5 | * @package LivePersonInc\LiveEngageLaravel\Collections |
||
6 | */ |
||
7 | |||
8 | namespace LivePersonInc\LiveEngageLaravel\Collections; |
||
9 | |||
10 | use Illuminate\Support\Collection; |
||
11 | use LivePersonInc\LiveEngageLaravel\Models\Message; |
||
12 | use LivePersonInc\LiveEngageLaravel\Models\Agent; |
||
13 | |||
14 | /** |
||
15 | * Transcript class. |
||
16 | * |
||
17 | * @extends Collection |
||
18 | */ |
||
19 | class Transcript extends Collection |
||
20 | { |
||
21 | 2 | public function __construct(array $models = [], $agents = false) |
|
22 | { |
||
23 | $models = array_map(function($item) use ($agents) { |
||
24 | 2 | if (property_exists($item, 'sentBy') && $item->sentBy == 'Agent' && $agents) { |
|
25 | 1 | $item->agentDetails = $agents->findById($item->participantId); |
|
26 | } |
||
27 | 2 | return new Message((array) $item); |
|
28 | 2 | }, $models); |
|
29 | 2 | return parent::__construct($models); |
|
0 ignored issues
–
show
|
|||
30 | } |
||
31 | |||
32 | public function textTranscript() |
||
33 | { |
||
34 | $text = ""; |
||
35 | foreach ($this as $message) { |
||
36 | $by = $message->sentBy == 'Agent' ? $message->agentDetails->agentFullName : 'Visitor'; |
||
37 | $text .= "{$by}:\n{$message->plainText}\n\n"; |
||
38 | } |
||
39 | return $text; |
||
40 | } |
||
41 | } |
||
42 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.