Code Duplication    Length = 45-47 lines in 2 locations

module/Applications/src/Applications/Entity/Contact.php 1 location

@@ 26-72 (lines=47) @@
23
 * @author Mathias Gelhausen <[email protected]>
24
 * @ODM\EmbeddedDocument
25
 */
26
class Contact extends Info
27
{
28
29
    /**
30
     * profile image of an application.
31
     *
32
     * As contact image is stored as an {@link Applications\Entity\Attachment} it must be
33
     * redeclared here.
34
     *
35
     * @var \Core\Entity\FileInterface
36
     * @ODM\ReferenceOne(targetDocument="Attachment", simple=true, nullable=true, cascade={"persist", "update", "remove"}, orphanRemoval=true)
37
     */
38
    protected $image;
39
    
40
    /**
41
     * Creates a Contact
42
     *
43
     * @param InfoInterface|null $userInfo
44
     * @uses inherit()
45
     */
46
    public function __construct(InfoInterface $userInfo = null)
47
    {
48
        if ($userInfo) {
49
            $this->inherit($userInfo);
50
        }
51
    }
52
53
    /**
54
     * Inherit data from an {@link UserInfoInterface}.
55
     *
56
     * Copies the user image to an application attachment.
57
     * @param InfoInterface $info
58
     * @return $this
59
     */
60
    public function inherit(InfoInterface $info)
61
    {
62
        $hydrator      = new EntityHydrator();
63
        $imageStrategy = new FileCopyStrategy(new Attachment());
64
        
65
        $hydrator->addStrategy('image', $imageStrategy);
66
        
67
        $data = $hydrator->extract($info);
68
        $hydrator->hydrate($data, $this);
69
        
70
        return $this;
71
    }
72
}
73

module/Cv/src/Cv/Entity/Contact.php 1 location

@@ 23-67 (lines=45) @@
20
 *
21
 * @ODM\EmbeddedDocument
22
 */
23
class Contact extends Info
24
{
25
26
    /**
27
     * Contact image
28
     *
29
     * @var ContactImage
30
     * @ODM\ReferenceOne(targetDocument="\Cv\Entity\ContactImage", simple=true, nullable=true, cascade={"persist"})
31
     * @ODM\Index
32
     */
33
    protected $image;
34
    
35
    /**
36
     * Creates a Contact
37
     *
38
     * @param InfoInterface|null $userInfo
39
     * @uses inherit()
40
     */
41
    public function __construct(InfoInterface $userInfo = null)
42
    {
43
        if ($userInfo) {
44
            $this->inherit($userInfo);
45
        }
46
    }
47
48
    /**
49
     * Inherit data from an {@link UserInfoInterface}.
50
     *
51
     * Copies the user image to an application attachment.
52
     * @param InfoInterface $info
53
     * @return $this
54
     */
55
    public function inherit(InfoInterface $info)
56
    {
57
        $hydrator      = new EntityHydrator();
58
        $imageStrategy = new FileCopyStrategy(new ContactImage());
59
        
60
        $hydrator->addStrategy('image', $imageStrategy);
61
        
62
        $data = $hydrator->extract($info);
63
        $hydrator->hydrate($data, $this);
64
        
65
        return $this;
66
    }
67
}
68