Completed
Push — master ( 70cb44...646998 )
by Ivannis Suárez
05:28
created

Post   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 63
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A title() 0 4 1
A content() 0 4 1
A equals() 0 7 3
A loadValidatorMetadata() 0 8 1
1
<?php
2
3
/**
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Cubiche\Core\Validator\Tests\Fixtures;
12
13
use Cubiche\Core\Validator\Assert;
14
use Cubiche\Core\Validator\Mapping\ClassMetadata;
15
16
/**
17
 * Post class.
18
 *
19
 * @author Ivannis Suárez Jerez <[email protected]>
20
 */
21
class Post
22
{
23
    /**
24
     * @var string
25
     */
26
    protected $title;
27
28
    /**
29
     * @var string
30
     */
31
    protected $content;
32
33
    /**
34
     * Post constructor.
35
     *
36
     * @param string $title
37
     * @param string $content
38
     */
39
    public function __construct($title = null, $content = null)
40
    {
41
        $this->title = $title;
42
        $this->content = $content;
43
    }
44
45
    /**
46
     * @return string
47
     */
48
    public function title()
49
    {
50
        return $this->title;
51
    }
52
53
    /**
54
     * @return string
55
     */
56
    public function content()
57
    {
58
        return $this->content;
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function equals($other)
65
    {
66
        return parent::equals($other) &&
67
            $this->title() == $other->title() &&
68
            $this->content() == $other->content()
69
        ;
70
    }
71
72
    /**
73
     * {@inheritdoc}
74
     */
75
    public static function loadValidatorMetadata(ClassMetadata $classMetadata)
76
    {
77
        $classMetadata->addPropertyConstraint('title', Assert::stringType()->notBlank());
0 ignored issues
show
Compatibility introduced by
\Cubiche\Core\Validator\...tringType()->notBlank() of type object<Respect\Validation\Validator> is not a sub-type of object<Cubiche\Core\Validator\Assert>. It seems like you assume a child class of the class Respect\Validation\Validator to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
78
        $classMetadata->addPropertyConstraint('content', Assert::stringType());
0 ignored issues
show
Compatibility introduced by
\Cubiche\Core\Validator\Assert::stringType() of type object<Respect\Validation\Validator> is not a sub-type of object<Cubiche\Core\Validator\Assert>. It seems like you assume a child class of the class Respect\Validation\Validator to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
79
80
        $classMetadata->addPropertyConstraint('title', Assert::intType()->notBlank(), 'foo');
0 ignored issues
show
Compatibility introduced by
\Cubiche\Core\Validator\...::intType()->notBlank() of type object<Respect\Validation\Validator> is not a sub-type of object<Cubiche\Core\Validator\Assert>. It seems like you assume a child class of the class Respect\Validation\Validator to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
81
        $classMetadata->addPropertyConstraint('content', Assert::intType()->notBlank(), 'foo');
0 ignored issues
show
Compatibility introduced by
\Cubiche\Core\Validator\...::intType()->notBlank() of type object<Respect\Validation\Validator> is not a sub-type of object<Cubiche\Core\Validator\Assert>. It seems like you assume a child class of the class Respect\Validation\Validator to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
82
    }
83
}
84