http://phing.info/

Source Code Coverage

Designed for use with PHPUnit2, Xdebug and Phing.

Methods: 10 LOC: 139 Statements: 18

Source file Statements Methods Total coverage
Field.php 100.0% 100.0% 100.0%
 
1
<?php
2
/**
3
 * Xyster Framework
4
 *
5
 * This source file is subject to the new BSD license that is bundled
6
 * with this package in the file LICENSE.txt.
7
 * It is also available through the world-wide-web at this URL:
8
 * http://www.opensource.org/licenses/bsd-license.php
9
 *
10
 * @category  Xyster
11
 * @package   Xyster_Orm
12
 * @copyright Copyright (c) 2007-2008 Irrational Logic (http://irrationallogic.net)
13
 * @license   http://www.opensource.org/licenses/bsd-license.php New BSD License
14
 * @version   $Id: Field.php 202 2008-01-20 16:20:09Z doublecompile $
15
 */
16
/**
17
 * An field description object
18
 *
19
 * @category  Xyster
20
 * @package   Xyster_Orm
21
 * @copyright Copyright (c) 2007-2008 Irrational Logic (http://irrationallogic.net)
22
 * @license   http://www.opensource.org/licenses/bsd-license.php New BSD License
23
 */
24
class Xyster_Orm_Entity_Field
25
{
26
    protected $_name;
27
    protected $_original;
28
    protected $_type;
29
    protected $_length;
30
    protected $_default;
31
    protected $_null;
32
    protected $_primary;
33
    protected $_primaryPosition;
34
    protected $_identity;
35
36
    /**
37
     * Create a new entity field
38
     *
39
     * The array passed should be in the format returned by the describeTable
40
     * method of the Zend_Db_Adapter_Abstract class
41
     *
42
     * @see Zend_Db_Adapter_Abstract::describeTable
43
     * @param array $details
44
     */
45
    public function __construct( $name, array $details )
46
    {
47 223
        $this->_name = $name;
48 223
        $this->_original = $details['COLUMN_NAME'];
49 223
        $this->_type = $details['DATA_TYPE'];
50 223
        $this->_length = $details['LENGTH'];
51 223
        $this->_null = $details['NULLABLE'];
52 223
        $this->_default = $details['DEFAULT'];
53 223
        $this->_primary = $details['PRIMARY'];
54 223
        $this->_primaryPosition = $details['PRIMARY_POSITION'];
55 223
        $this->_identity = (isset($details['IDENTITY'])) ? $details['IDENTITY'] : null;
56
    }
57
58
    /**
59
     * Gets the name of the field
60
     *
61
     * @return string
62
     */
63
    public function getName()
64
    {
65 1
        return $this->_name;
66
    }
67
    /**
68
     * Gets the original name
69
     *
70
     * @return string
71
     */
72
    public function getOriginalName()
73
    {
74 1
        return $this->_original;
75
    }
76
    /**
77
     * Gets the native type of the field
78
     *
79
     * @return string
80
     */
81
    public function getType()
82
    {
83 1
        return $this->_type;
84
    }
85
    /**
86
     * Gets the length of the field
87
     *
88
     * @return int
89
     */
90
    public function getLength()
91
    {
92 1
        return $this->_length;
93
    }
94
    /**
95
     * Gets whether the field can have a null value
96
     *
97
     * @return boolean
98
     */
99
    public function isNullable()
100
    {
101 1
        return $this->_null;
102
    }
103
    /**
104
     * Gets the default value for the field
105
     *
106
     * @return boolean
107
     */
108
    public function getDefault()
109
    {
110 1
        return $this->_default;
111
    }
112
    /**
113
     * Gets whether the field is part of a primary key
114
     *
115
     * @return boolean
116
     */
117
    public function isPrimary()
118
    {
119 223
        return $this->_primary;
120
    }
121
    /**
122
     * Gets the index of this field in the primary key
123
     *
124
     * @return int
125
     */
126
    public function getPrimaryPosition()
127
    {
128 4
        return $this->_primaryPosition;
129
    }
130
    /**
131
     * Gets whether the field uses an autonumbering scheme
132
     *
133
     * @return boolean
134
     */
135
    public function isIdentity()
136
    {
137 4
        return $this->_identity;
138
    }
139
}


Report generated at 2008-01-20T12:13:38-05:00