GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Setup Failed
Push — email_fix ( a1c2be )
by
unknown
09:01
created

SendMailHandler::submissionsSendMail()   C

Complexity

Conditions 8
Paths 39

Size

Total Lines 49
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 49
rs 6.1404
cc 8
eloc 30
nc 39
nop 1
1
<?php
2
3
namespace app\modules\core\components\mail;
4
5
6
use app\models\Submission;
7
use yii\base\Event;
8
use Yii;
9
10
11
class SendMailHandler
12
{
13
14
    public static function submissionsSendMail(Event $event)
15
    {
16
17
        if (!empty($event->sender->form->email_notification_addresses)) {
18
            try {
19
                $emailView = !empty($event->sender->form->email_notification_view)
20
                    ? $event->sender->form->email_notification_view
21
                    : '@app/widgets/form/views/email-template.php';
22
23
                /** @var \app\modules\core\components\MailComponent $mail */
24
                $mail = \Yii::$app->mail;
25
                $msg = $mail->compose(
26
                    $emailView,
27
                    [
28
                        'form' => $event->sender->form,
29
                        'submission' => $event->sender,
30
                    ]
31
                )->setTo(explode(',', $event->sender->form->email_notification_addresses))->setFrom(
32
                    \Yii::$app->mail->getMailFrom()
33
                )->setSubject($event->sender->getSubject());
34
35
                if (\Yii::$app->getModule('core')->attachFilePropertiesToFormEmail === true) {
36
                    $properties = $event->sender->abstractModel->getPropertiesModels();
37
                    $basePath = Yii::getAlias(Yii::$app->getModule('core')->visitorsFileUploadPath) . '/';
38
                    foreach ($properties as $property) {
39
                        /** @var \app\models\Property $property */
40
                        if (stripos($property->getHandler()->handler_class_name, 'FileInput') !== false) {
41
                            $filename = $basePath . $event->sender->property($property->key);
42
                            $msg = $msg->attach($filename);
43
                        }
44
                    }
45
                }
46
47
                if ($msg->send()) {
48
                    $event->sender->sending_status = Submission::STATUS_SUCCESS;
49
                }
50
51
            } catch (\Exception $e) {
52
                echo "Exception\n";
53
                $event->sender->sending_status = Submission::STATUS_ERROR;
54
                $event->sender->internal_comment = $e->getMessage() . "\n\n" . $e->getFile() . ":" . $e->getLine();
55
                echo $e->getMessage() . "\n\n" . $e->getFile() . ":" . $e->getLine();
56
            }
57
        } else {
58
            echo "No email\n";
59
        }
60
61
62
    }
63
64
}