Completed
Push — master ( 46961e...b2acd3 )
by Axel
04:17 queued 01:11
created

FeatureManager::createProductOwnerFeature()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 17
ccs 15
cts 15
cp 1
rs 9.4285
cc 1
eloc 15
nc 1
nop 6
crap 1
1
<?php
2
3
namespace Developtech\AgilityBundle\Manager;
4
5
use Developtech\AgilityBundle\Model\ProjectModel;
6
7
use Developtech\AgilityBundle\Entity\Feature;
8
9
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
10
11
class FeatureManager extends JobManager {
12
    /**
13
     * @param ProjectModel $project
14
     * @return array
15
     */
16 1
    public function getProjectFeatures(ProjectModel $project) {
17 1
        return $this->em->getRepository(Feature::class)->findByProject($project);
18
    }
19
20
    /**
21
     * @param integer $id
22
     * @return Feature
23
     */
24 2
    public function getFeature($id) {
25 2
        if(($feature = $this->em->getRepository(Feature::class)->find($id)) === null) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
26 1
            throw new NotFoundHttpException('Feature not found');
27
        }
28 1
        return $feature;
29
    }
30
31
    /**
32
    *  @param ProjectModel $project
33
     * @param string $name
34
     * @param string $description
35
     * @param integer $status
36
     * @param integer $productOwnerValue
37
     * @param UserInterface $responsible
38
     * @return Feature
39
     */
40 1
    public function createProductOwnerFeature(ProjectModel $project, $name, $description, $status, $productOwnerValue = null, $responsible = null) {
41
        $feature =
42 1
            (new Feature())
43 1
            ->setProject($project)
44 1
            ->setFeatureType(Feature::FEATURE_TYPE_PRODUCT_OWNER)
45 1
            ->setName($name)
46 1
            ->setSlug($this->slugger->slugify($name))
47 1
            ->setDescription($description)
48 1
            ->setStatus($status)
49 1
            ->setProductOwnerValue($productOwnerValue)
50 1
            ->setResponsible($responsible)
51 1
        ;
52 1
        $project->addFeature($feature);
53 1
        $this->em->persist($feature);
54 1
        $this->em->flush();
55 1
        return $feature;
56
    }
57
}
58