Passed
Push — master ( 240c83...03f39b )
by Mathias
06:41
created

Cv::createFromApplication()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 40
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 24
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
c 1
b 0
f 0
dl 0
loc 40
ccs 24
cts 24
cp 1
rs 9.552
cc 3
nc 2
nop 2
crap 3
1
<?php
2
3
namespace Cv\Repository;
4
5
use Applications\Entity\Attachment;
6
use Core\Entity\PermissionsInterface;
7
use Core\Repository\DraftableEntityAwareInterface;
8
use Core\Repository\DraftableEntityAwareTrait;
9
use Core\Repository\AbstractRepository;
10
use Auth\Entity\UserInterface;
11
use Applications\Entity\Application;
12
use Cv\Entity\Cv as CvEntity;
13
14
/**
15
 * class for accessing CVs
16
 *
17
 * @method CvEntity create(array $data = null, $persist = false)
18
 */
19
class Cv extends AbstractRepository implements DraftableEntityAwareInterface
20
{
21
    use DraftableEntityAwareTrait;
22
23
    /**
24
     * Look for an drafted Document of a given user
25
     *
26
     * @param object|UserInterface $user
27
     * @return CvEntity|null
28 1
     */
29
    public function findDraft($user)
30 1
    {
31 1
        if ($user instanceof UserInterface) {
32
            $user = $user->getId();
33
        }
34 1
35
        return $this->findOneDraftBy(['user' => $user]);
36
    }
37
}
38