ImageManagerServices::getUploadDir()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: device
5
 * Date: 29.01.16
6
 * Time: 17:07
7
 */
8
9
namespace AppBundle\Services;
10
11
12
use AppBundle\Entity\Module;
13
14
15
/**
16
 * Class ImageManagerServices
17
 * @package AppBundle\Service
18
 */
19
class ImageManagerServices
20
{
21
22
    /**
23
     * @return string
24
     */
25
    protected function getUploadRootDir()
26
    {
27
        return __DIR__ . '/../../../web/' . $this->getUploadDir();
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    protected function getUploadDir()
34
    {
35
        return 'uploads/module';
36
    }
37
38
    /**
39
     * @param Module $module
40
     */
41
    public function upload(Module $module)
42
    {
43
        $randPrefix = mt_rand(1, 9999);
44
        $module->getModuleImage()->move(
0 ignored issues
show
Bug introduced by
The method move cannot be called on $module->getModuleImage() (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
45
            $this->getUploadRootDir(),
46
            $randPrefix . '-' . $module->getModuleImage()->getClientOriginalName()
0 ignored issues
show
Bug introduced by
The method getClientOriginalName cannot be called on $module->getModuleImage() (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
47
        );
48
        $module->setPathImage($this->getUploadDir() . '/' . $randPrefix . '-' . $module->getModuleImage()->getClientOriginalName());
0 ignored issues
show
Bug introduced by
The method getClientOriginalName cannot be called on $module->getModuleImage() (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
49
        $module->setNameImage($randPrefix . '-' . $module->getModuleImage()->getClientOriginalName());
0 ignored issues
show
Bug introduced by
The method getClientOriginalName cannot be called on $module->getModuleImage() (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
50
        $module->setModuleImage(null);
51
52
        return;
53
    }
54
}