ArticleVote::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 21
rs 9.584
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Alpha\Model;
4
5
use Alpha\Model\Type\Integer;
6
use Alpha\Model\Type\Relation;
7
use Alpha\Util\Logging\Logger;
8
9
/**
10
 * An article vote class for user ratings.
11
 *
12
 * @since 1.0
13
 *
14
 * @author John Collins <[email protected]>
15
 * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
16
 * @copyright Copyright (c) 2018, John Collins (founder of Alpha Framework).
17
 * All rights reserved.
18
 *
19
 * <pre>
20
 * Redistribution and use in source and binary forms, with or
21
 * without modification, are permitted provided that the
22
 * following conditions are met:
23
 *
24
 * * Redistributions of source code must retain the above
25
 *   copyright notice, this list of conditions and the
26
 *   following disclaimer.
27
 * * Redistributions in binary form must reproduce the above
28
 *   copyright notice, this list of conditions and the
29
 *   following disclaimer in the documentation and/or other
30
 *   materials provided with the distribution.
31
 * * Neither the name of the Alpha Framework nor the names
32
 *   of its contributors may be used to endorse or promote
33
 *   products derived from this software without specific
34
 *   prior written permission.
35
 *
36
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
37
 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
38
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
39
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
41
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
43
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
44
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
46
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
47
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
48
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49
 * </pre>
50
 */
51
class ArticleVote extends ActiveRecord
52
{
53
    /**
54
     * The article this comment belongs to.
55
     *
56
     * @var \Alpha\Model\Type\Relation
57
     *
58
     * @since 1.0
59
     */
60
    protected $articleID;
61
62
    /**
63
     * The person who cast the vote.
64
     *
65
     * @var \Alpha\Model\Type\Relation
66
     *
67
     * @since 1.0
68
     */
69
    protected $personID;
70
71
    /**
72
     * The actual vote score (default 1-10).
73
     *
74
     * @var \Alpha\Model\Type\Integer
75
     *
76
     * @since 1.0
77
     */
78
    protected $score;
79
80
    /**
81
     * An array of data display labels for the class properties.
82
     *
83
     * @var array
84
     *
85
     * @since 1.0
86
     */
87
    protected $dataLabels = array('ID' => 'Article Vote ID#', 'articleID' => 'Article', 'personID' => 'Voter', 'score' => 'Article Score');
88
89
    /**
90
     * The name of the database table for the class.
91
     *
92
     * @var string
93
     *
94
     * @since 1.0
95
     */
96
    const TABLE_NAME = 'ArticleVote';
97
98
    /**
99
     * Trace logger.
100
     *
101
     * @var \Alpha\Util\Logging\Logger
102
     *
103
     * @since 1.1
104
     */
105
    private static $logger = null;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
106
107
    /**
108
     * Constructor for the class.
109
     *
110
     * @since 1.0
111
     */
112
    public function __construct()
113
    {
114
        self::$logger = new Logger('ArticleVote');
115
116
        // ensure to call the parent constructor
117
        parent::__construct();
118
119
        $this->articleID = new Relation();
120
        $this->articleID->setRelatedClass('Alpha\Model\Article');
121
        $this->articleID->setRelatedClassField('ID');
122
        $this->articleID->setRelatedClassDisplayField('description');
123
        $this->articleID->setRelationType('MANY-TO-ONE');
124
125
        $this->personID = new Relation();
126
        $this->personID->setRelatedClass('Alpha\Model\Person');
127
        $this->personID->setRelatedClassField('ID');
128
        $this->personID->setRelatedClassDisplayField('email');
129
        $this->personID->setRelationType('MANY-TO-ONE');
130
131
        $this->score = new Integer();
132
    }
133
}
134