FakeSmsSender::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace HoomanMirghasemi\Sms\Drivers;
4
5
use HoomanMirghasemi\Sms\Abstracts\Driver;
6
7
class FakeSmsSender extends Driver
8
{
9
    /**
10
     * The Faker sms send sms success of fail.
11
     *
12
     * @var bool
13
     */
14
    public static bool $successSend = true;
15
16
    public function __construct(protected array $settings)
17
    {
18
        $this->from = data_get($this->settings, 'from');
19
    }
20
21
    /**
22
     * Send sms method for Magfa.
23
     *
24
     * This method send sms and save log to db.
25
     *
26
     * @return bool
27
     */
28
    public function send(): bool
29
    {
30
        if (!self::$successSend) {
31
            $this->webserviceResponse = 'An error happened !';
32
            $this->success = false;
33
        } else {
34
            $this->webserviceResponse = 'Message has been successfully sent ; MessageId : '.rand(1, 1000000);
35
            $this->success = true;
36
        }
37
38
        return parent::send();
39
    }
40
41
    /**
42
     * Return fake balance :D.
43
     *
44
     * @return string
45
     */
46
    public function getBalance(): string
47
    {
48
        return rand(0, 250000);
49
    }
50
}
51