Passed
Push — master ( 909f95...9b2dc9 )
by Romain
08:25 queued 05:32
created

CommentAddedEvent::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * Copyright (C) 2018
6
 * Nathan Boiron <[email protected]>
7
 * Romain Canon <[email protected]>
8
 *
9
 * This file is part of the TYPO3 NotiZ project.
10
 * It is free software; you can redistribute it and/or modify it
11
 * under the terms of the GNU General Public License, either
12
 * version 3 of the License, or any later version.
13
 *
14
 * For the full copyright and license information, see:
15
 * http://www.gnu.org/licenses/gpl-3.0.html
16
 */
17
18
namespace CuyZ\Notiz\Domain\Event\Blog;
19
20
use CuyZ\Notiz\Core\Event\AbstractEvent;
21
use CuyZ\Notiz\Core\Event\Support\ProvidesExampleProperties;
22
use DateTime;
23
use T3G\AgencyPack\Blog\Domain\Model\Comment;
0 ignored issues
show
Bug introduced by
The type T3G\AgencyPack\Blog\Domain\Model\Comment was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
use T3G\AgencyPack\Blog\Domain\Model\Post;
0 ignored issues
show
Bug introduced by
The type T3G\AgencyPack\Blog\Domain\Model\Post was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
use T3G\AgencyPack\Blog\Notification\CommentAddedNotification;
0 ignored issues
show
Bug introduced by
The type T3G\AgencyPack\Blog\Noti...ommentAddedNotification was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
use TYPO3\CMS\Extbase\Domain\Model\FrontendUser;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Extbase\Domain\Model\FrontendUser was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
27
28
class CommentAddedEvent extends AbstractEvent implements ProvidesExampleProperties
29
{
30
    /**
31
     * @label Event/Blog:comment_added.marker.comment
32
     * @marker
33
     *
34
     * @var Comment
35
     */
36
    protected $comment;
37
38
    /**
39
     * @label Event/Blog:comment_added.marker.post
40
     * @marker
41
     *
42
     * @var Post
43
     */
44
    protected $post;
45
46
    /**
47
     * @label Event/Blog:comment_added.email.comment_email
48
     * @email
49
     *
50
     * @var array
51
     */
52
    protected $commentEmail;
53
54
    /**
55
     * @param CommentAddedNotification $commentAddedNotification
56
     */
57
    public function run(CommentAddedNotification $commentAddedNotification)
58
    {
59
        $data = $commentAddedNotification->getData();
60
61
        $this->comment = $data['comment'];
62
        $this->post = $data['post'];
63
64
        $this->commentEmail = $this->comment->getEmail();
65
    }
66
67
    /**
68
     * @return array
69
     */
70
    public function getExampleProperties(): array
71
    {
72
        $author = new FrontendUser();
73
        $author->setName('John Doe');
74
75
        $post = new Post();
76
        $post->setTitle('My awesome post!');
77
        $post->setSubtitle('This is so awesome!');
78
        $post->setAbstract('The abstract of my post');
79
        $post->setDescription('Some awesome description for an awesome post.');
80
        $post->setCrdate(new DateTime());
81
82
        $comment = new Comment();
83
        $comment->setAuthor($author);
84
        $comment->setName('Some comment');
85
        $comment->setEmail('[email protected]');
86
        $comment->setUrl('https://example.com');
87
        $comment->setComment('This is an awesome comment!');
88
        $comment->setPost($post);
89
        $comment->setCrdate(new DateTime());
90
91
        return [
92
            'comment' => $comment,
93
            'post' => $post,
94
            'commentEmail' => '[email protected]',
95
        ];
96
    }
97
}
98