Completed
Push — 1.9 ( d8eb28...5c3e2e )
by
unknown
61:52 queued 29s
created

CreateActivityAssociation   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 2
dl 56
loc 56
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setActivityExtension() 4 4 1
A setNoteExtension() 4 4 1
A addNoteAssociations() 4 4 1
A up() 5 5 1
A addActivityAssociations() 5 5 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace OroCRM\Bundle\MagentoBundle\Migrations\Schema\v1_40;
4
5
use Doctrine\DBAL\Schema\Schema;
6
7
use Oro\Bundle\ActivityBundle\Migration\Extension\ActivityExtension;
8
use Oro\Bundle\ActivityBundle\Migration\Extension\ActivityExtensionAwareInterface;
9
use Oro\Bundle\NoteBundle\Migration\Extension\NoteExtension;
10
use Oro\Bundle\NoteBundle\Migration\Extension\NoteExtensionAwareInterface;
11
use Oro\Bundle\MigrationBundle\Migration\Migration;
12
use Oro\Bundle\MigrationBundle\Migration\QueryBag;
13
14 View Code Duplication
class CreateActivityAssociation implements Migration, ActivityExtensionAwareInterface, NoteExtensionAwareInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
{
16
    /** @var ActivityExtension */
17
    protected $activityExtension;
18
19
    /** @var NoteExtension */
20
    protected $noteExtension;
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function setActivityExtension(ActivityExtension $activityExtension)
26
    {
27
        $this->activityExtension = $activityExtension;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function setNoteExtension(NoteExtension $noteExtension)
34
    {
35
        $this->noteExtension = $noteExtension;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function up(Schema $schema, QueryBag $queries)
42
    {
43
        self::addActivityAssociations($schema, $this->activityExtension);
44
        self::addNoteAssociations($schema, $this->noteExtension);
45
    }
46
47
    /**
48
     * Enable activities
49
     *
50
     * @param Schema            $schema
51
     * @param ActivityExtension $activityExtension
52
     */
53
    public static function addActivityAssociations(Schema $schema, ActivityExtension $activityExtension)
54
    {
55
        $activityExtension->addActivityAssociation($schema, 'orocrm_task', 'orocrm_magento_order');
56
        $activityExtension->addActivityAssociation($schema, 'oro_calendar_event', 'orocrm_magento_order');
57
    }
58
59
    /**
60
     * Enable notes for Magento Order entity
61
     *
62
     * @param Schema        $schema
63
     * @param NoteExtension $noteExtension
64
     */
65
    public static function addNoteAssociations(Schema $schema, NoteExtension $noteExtension)
66
    {
67
        $noteExtension->addNoteAssociation($schema, 'orocrm_magento_order');
68
    }
69
}
70