UpdateGuesser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supportAction() 0 7 1
A guessUpdates() 0 9 2
1
<?php
2
3
namespace Pim\Bundle\CustomEntityBundle\Versioning;
4
5
use Doctrine\ORM\EntityManager;
6
use Pim\Bundle\VersioningBundle\UpdateGuesser\UpdateGuesserInterface;
7
8
/**
9
 * Attribute option update guesser
10
 *
11
 * @author    Nicolas Dupont <[email protected]>
12
 * @copyright 2013 Akeneo SAS (http://www.akeneo.com)
13
 * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
14
 */
15
class UpdateGuesser implements UpdateGuesserInterface
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function supportAction($action)
21
    {
22
        return in_array(
23
            $action,
24
            array(UpdateGuesserInterface::ACTION_UPDATE_ENTITY, UpdateGuesserInterface::ACTION_DELETE)
25
        );
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function guessUpdates(EntityManager $em, $entity, $action)
32
    {
33
        $pendings = array();
34
        if ($entity instanceof VersionableInterface) {
35
            $pendings[] = $entity;
36
        }
37
38
        return $pendings;
39
    }
40
}
41