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

AbstractImage::getWebPath()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 6
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