Completed
Push — capistrano-3 ( 15aaa8...b5fc70 )
by Tijs
09:29 queued 06:48
created

AbstractImage   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 29
ccs 0
cts 12
cp 0
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getWebPath() 0 10 2
A getFallbackImage() 0 4 1
1
<?php
2
3
namespace SumoCoders\FrameworkCoreBundle\ValueObject;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
/**
8
 * The following things are mandatory to use this class.
9
 *
10
 * You need to implement the method getUploadDir.
11
 * When using this class in an entity certain life cycle callbacks should be called
12
 * prepareToUpload for @ORM\PrePersist() and @ORM\PreUpdate()
13
 * upload for @ORM\PostPersist() and @ORM\PostUpdate()
14
 * remove for @ORM\PostRemove()
15
 *
16
 * The following things are optional
17
 * A fallback image can be set by setting the full path of the image to the FALLBACK_IMAGE constant
18
 */
19
abstract class AbstractImage extends AbstractFile
20
{
21
    /**
22
     * @var string|null
23
     */
24
    const FALLBACK_IMAGE = null;
25
26
    /**
27
     * @return string
28
     */
29
    public function getWebPath()
30
    {
31
        $webPath = parent::getWebPath();
32
33
        if (empty($webPath)) {
34
            return static::FALLBACK_IMAGE;
35
        }
36
37
        return $webPath;
38
    }
39
40
    /**
41
     * @return null|string
42
     */
43
    public function getFallbackImage()
44
    {
45
        return static::FALLBACK_IMAGE;
46
    }
47
}
48