Passed
Push — develop ( 6dcea6...5ae9a6 )
by Septianata
16:24
created

OrderStatusCreated   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 9
c 1
b 0
f 0
dl 0
loc 34
ccs 0
cts 11
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTelegramChatId() 0 6 1
A getTelegramMessage() 0 5 1
A __construct() 0 2 1
1
<?php
2
3
namespace App\Events;
4
5
use App\Contracts\Event\CanSendTelegramNotification;
6
use App\Models\Order;
7
use App\Models\User;
8
use Illuminate\Broadcasting\InteractsWithSockets;
9
use Illuminate\Contracts\Queue\ShouldQueue;
10
use Illuminate\Foundation\Events\Dispatchable;
11
use Illuminate\Queue\InteractsWithQueue;
12
use Illuminate\Queue\SerializesModels;
13
14
class OrderStatusCreated implements CanSendTelegramNotification, ShouldQueue
15
{
16
    use Dispatchable, InteractsWithSockets, SerializesModels, InteractsWithQueue;
0 ignored issues
show
introduced by
The trait Illuminate\Queue\SerializesModels requires some properties which are not provided by App\Events\OrderStatusCreated: $id, $relations, $class, $connection, $keyBy
Loading history...
17
18
    /**
19
     * Create a new event instance.
20
     *
21
     * @param  \App\Models\Order  $order
22
     * @return void
23
     */
24
    public function __construct(protected Order $order)
25
    {
26
        //
27
    }
28
29
    /**
30
     * {@inheritDoc}
31
     */
32
    public function getTelegramChatId(): array
33
    {
34
        return User::getAdmin(['id', 'telegram_chat_id'])
35
            ->pluck('telegram_chat_id')
36
            ->push($this->order->customer->telegram_chat_id)
37
            ->toArray();
38
    }
39
40
    /**
41
     * {@inheritDoc}
42
     */
43
    public function getTelegramMessage(): string
44
    {
45
        return view('notifications.order-status-created', [
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('notificatio...this->order))->render() could return the type array which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
46
            'order' => $this->order,
47
        ])->render();
48
    }
49
}
50