Completed
Push — 4.0 ( b0bc74...f44cfe )
by David
04:47
created
src/Mouf/Database/TDBM/Utils/ScalarBeanPropertyDescriptor.php 1 patch
Indentation   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -11,98 +11,98 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class ScalarBeanPropertyDescriptor extends AbstractBeanPropertyDescriptor
13 13
 {
14
-    /**
15
-     * @var Column
16
-     */
17
-    private $column;
18
-
19
-    public function __construct(Table $table, Column $column)
20
-    {
21
-        parent::__construct($table);
22
-        $this->table = $table;
23
-        $this->column = $column;
24
-    }
25
-
26
-    /**
27
-     * Returns the foreign-key the column is part of, if any. null otherwise.
28
-     *
29
-     * @return ForeignKeyConstraint|null
30
-     */
31
-    public function getForeignKey()
32
-    {
33
-        return false;
34
-    }
35
-
36
-    /**
37
-     * Returns the param annotation for this property (useful for constructor).
38
-     *
39
-     * @return string
40
-     */
41
-    public function getParamAnnotation()
42
-    {
43
-        $className = $this->getClassName();
44
-        $paramType = $className ?: TDBMDaoGenerator::dbalTypeToPhpType($this->column->getType());
45
-
46
-        $str = '     * @param %s %s';
47
-
48
-        return sprintf($str, $paramType, $this->getVariableName());
49
-    }
50
-
51
-    public function getUpperCamelCaseName()
52
-    {
53
-        return TDBMDaoGenerator::toCamelCase($this->column->getName());
54
-    }
55
-
56
-    /**
57
-     * Returns the name of the class linked to this property or null if this is not a foreign key.
58
-     *
59
-     * @return null|string
60
-     */
61
-    public function getClassName()
62
-    {
63
-        return;
64
-    }
65
-
66
-    /**
67
-     * Returns true if the property is compulsory (and therefore should be fetched in the constructor).
68
-     *
69
-     * @return bool
70
-     */
71
-    public function isCompulsory()
72
-    {
73
-        return $this->column->getNotnull() && !$this->column->getAutoincrement();
74
-    }
75
-
76
-    /**
77
-     * Returns true if the property is the primary key.
78
-     *
79
-     * @return bool
80
-     */
81
-    public function isPrimaryKey()
82
-    {
83
-        return in_array($this->column->getName(), $this->table->getPrimaryKeyColumns());
84
-    }
85
-
86
-    /**
87
-     * Returns the PHP code for getters and setters.
88
-     *
89
-     * @return string
90
-     */
91
-    public function getGetterSetterCode()
92
-    {
93
-        $type = $this->column->getType();
94
-        $normalizedType = TDBMDaoGenerator::dbalTypeToPhpType($type);
95
-
96
-        $columnGetterName = $this->getGetterName();
97
-        $columnSetterName = $this->getSetterName();
98
-
99
-        if ($normalizedType == '\\DateTimeInterface') {
100
-            $castTo = '\\DateTimeInterface ';
101
-        } else {
102
-            $castTo = '';
103
-        }
104
-
105
-        $getterAndSetterCode = '    /**
14
+	/**
15
+	 * @var Column
16
+	 */
17
+	private $column;
18
+
19
+	public function __construct(Table $table, Column $column)
20
+	{
21
+		parent::__construct($table);
22
+		$this->table = $table;
23
+		$this->column = $column;
24
+	}
25
+
26
+	/**
27
+	 * Returns the foreign-key the column is part of, if any. null otherwise.
28
+	 *
29
+	 * @return ForeignKeyConstraint|null
30
+	 */
31
+	public function getForeignKey()
32
+	{
33
+		return false;
34
+	}
35
+
36
+	/**
37
+	 * Returns the param annotation for this property (useful for constructor).
38
+	 *
39
+	 * @return string
40
+	 */
41
+	public function getParamAnnotation()
42
+	{
43
+		$className = $this->getClassName();
44
+		$paramType = $className ?: TDBMDaoGenerator::dbalTypeToPhpType($this->column->getType());
45
+
46
+		$str = '     * @param %s %s';
47
+
48
+		return sprintf($str, $paramType, $this->getVariableName());
49
+	}
50
+
51
+	public function getUpperCamelCaseName()
52
+	{
53
+		return TDBMDaoGenerator::toCamelCase($this->column->getName());
54
+	}
55
+
56
+	/**
57
+	 * Returns the name of the class linked to this property or null if this is not a foreign key.
58
+	 *
59
+	 * @return null|string
60
+	 */
61
+	public function getClassName()
62
+	{
63
+		return;
64
+	}
65
+
66
+	/**
67
+	 * Returns true if the property is compulsory (and therefore should be fetched in the constructor).
68
+	 *
69
+	 * @return bool
70
+	 */
71
+	public function isCompulsory()
72
+	{
73
+		return $this->column->getNotnull() && !$this->column->getAutoincrement();
74
+	}
75
+
76
+	/**
77
+	 * Returns true if the property is the primary key.
78
+	 *
79
+	 * @return bool
80
+	 */
81
+	public function isPrimaryKey()
82
+	{
83
+		return in_array($this->column->getName(), $this->table->getPrimaryKeyColumns());
84
+	}
85
+
86
+	/**
87
+	 * Returns the PHP code for getters and setters.
88
+	 *
89
+	 * @return string
90
+	 */
91
+	public function getGetterSetterCode()
92
+	{
93
+		$type = $this->column->getType();
94
+		$normalizedType = TDBMDaoGenerator::dbalTypeToPhpType($type);
95
+
96
+		$columnGetterName = $this->getGetterName();
97
+		$columnSetterName = $this->getSetterName();
98
+
99
+		if ($normalizedType == '\\DateTimeInterface') {
100
+			$castTo = '\\DateTimeInterface ';
101
+		} else {
102
+			$castTo = '';
103
+		}
104
+
105
+		$getterAndSetterCode = '    /**
106 106
      * The getter for the "%s" column.
107 107
      *
108 108
      * @return %s
@@ -122,50 +122,50 @@  discard block
 block discarded – undo
122 122
 
123 123
 ';
124 124
 
125
-        return sprintf($getterAndSetterCode,
126
-            // Getter
127
-            $this->column->getName(),
128
-            $normalizedType,
129
-            $columnGetterName,
130
-            var_export($this->column->getName(), true),
131
-            var_export($this->table->getName(), true),
132
-            // Setter
133
-            $this->column->getName(),
134
-            $normalizedType,
135
-            $this->column->getName(),
136
-            $columnSetterName,
137
-            $castTo,
138
-            $this->column->getName(),
139
-            var_export($this->column->getName(), true),
140
-            $this->column->getName(),
141
-            var_export($this->table->getName(), true)
142
-        );
143
-    }
144
-
145
-    /**
146
-     * Returns the part of code useful when doing json serialization.
147
-     *
148
-     * @return string
149
-     */
150
-    public function getJsonSerializeCode()
151
-    {
152
-        $type = $this->column->getType();
153
-        $normalizedType = TDBMDaoGenerator::dbalTypeToPhpType($type);
154
-
155
-        if ($normalizedType == '\\DateTimeInterface') {
156
-            return '        $array['.var_export($this->getLowerCamelCaseName(), true).'] = ($this->'.$this->getGetterName().'() === null)?null:$this->'.$this->getGetterName()."()->format('c');\n";
157
-        } else {
158
-            return '        $array['.var_export($this->getLowerCamelCaseName(), true).'] = $this->'.$this->getGetterName()."();\n";
159
-        }
160
-    }
161
-
162
-    /**
163
-     * Returns the column name.
164
-     *
165
-     * @return string
166
-     */
167
-    public function getColumnName()
168
-    {
169
-        return $this->column->getName();
170
-    }
125
+		return sprintf($getterAndSetterCode,
126
+			// Getter
127
+			$this->column->getName(),
128
+			$normalizedType,
129
+			$columnGetterName,
130
+			var_export($this->column->getName(), true),
131
+			var_export($this->table->getName(), true),
132
+			// Setter
133
+			$this->column->getName(),
134
+			$normalizedType,
135
+			$this->column->getName(),
136
+			$columnSetterName,
137
+			$castTo,
138
+			$this->column->getName(),
139
+			var_export($this->column->getName(), true),
140
+			$this->column->getName(),
141
+			var_export($this->table->getName(), true)
142
+		);
143
+	}
144
+
145
+	/**
146
+	 * Returns the part of code useful when doing json serialization.
147
+	 *
148
+	 * @return string
149
+	 */
150
+	public function getJsonSerializeCode()
151
+	{
152
+		$type = $this->column->getType();
153
+		$normalizedType = TDBMDaoGenerator::dbalTypeToPhpType($type);
154
+
155
+		if ($normalizedType == '\\DateTimeInterface') {
156
+			return '        $array['.var_export($this->getLowerCamelCaseName(), true).'] = ($this->'.$this->getGetterName().'() === null)?null:$this->'.$this->getGetterName()."()->format('c');\n";
157
+		} else {
158
+			return '        $array['.var_export($this->getLowerCamelCaseName(), true).'] = $this->'.$this->getGetterName()."();\n";
159
+		}
160
+	}
161
+
162
+	/**
163
+	 * Returns the column name.
164
+	 *
165
+	 * @return string
166
+	 */
167
+	public function getColumnName()
168
+	{
169
+		return $this->column->getName();
170
+	}
171 171
 }
Please login to merge, or discard this patch.