Completed
Pull Request — 3.4 (#46)
by David
13:58
created
src/Mouf/Database/TDBM/Utils/ScalarBeanPropertyDescriptor.php 2 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,8 +27,7 @@
 block discarded – undo
27 27
     /**
28 28
      * Returns the foreignkey the column is part of, if any. null otherwise.
29 29
      *
30
-     * @param Column $column
31
-     * @return ForeignKeyConstraint|null
30
+     * @return boolean
32 31
      */
33 32
     public function getForeignKey() {
34 33
         return false;
Please login to merge, or discard this patch.
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -12,88 +12,88 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class ScalarBeanPropertyDescriptor extends AbstractBeanPropertyDescriptor
14 14
 {
15
-    /**
16
-     * @var Column
17
-     */
18
-    private $column;
19
-
20
-
21
-    public function __construct(Table $table, Column $column) {
22
-        parent::__construct($table);
23
-        $this->table = $table;
24
-        $this->column = $column;
25
-    }
26
-
27
-    /**
28
-     * Returns the foreignkey the column is part of, if any. null otherwise.
29
-     *
30
-     * @param Column $column
31
-     * @return ForeignKeyConstraint|null
32
-     */
33
-    public function getForeignKey() {
34
-        return false;
35
-    }
36
-
37
-    /**
38
-     * Returns the param annotation for this property (useful for constructor).
39
-     *
40
-     * @return string
41
-     */
42
-    public function getParamAnnotation() {
43
-        $className = $this->getClassName();
44
-        $paramType = $className ?: TDBMDaoGenerator::dbalTypeToPhpType($this->column->getType());
45
-
46
-        $str = "     * @param %s %s";
47
-        return sprintf($str, $paramType, $this->getVariableName());
48
-    }
49
-
50
-    public function getUpperCamelCaseName() {
51
-        return TDBMDaoGenerator::toCamelCase($this->column->getName());
52
-    }
53
-
54
-    /**
55
-     * Returns the name of the class linked to this property or null if this is not a foreign key
56
-     * @return null|string
57
-     */
58
-    public function getClassName() {
59
-        return null;
60
-    }
61
-
62
-    /**
63
-     * Returns true if the property is compulsory (and therefore should be fetched in the constructor).
64
-     * @return bool
65
-     */
66
-    public function isCompulsory() {
67
-        return $this->column->getNotnull() && !$this->column->getAutoincrement();
68
-    }
69
-
70
-    /**
71
-     * Returns true if the property is the primary key
72
-     * @return bool
73
-     */
74
-    public function isPrimaryKey() {
75
-        return in_array($this->column->getName(), $this->table->getPrimaryKeyColumns());
76
-    }
77
-
78
-    /**
79
-     * Returns the PHP code for getters and setters
80
-     * @return string
81
-     */
82
-    public function getGetterSetterCode() {
83
-
84
-        $type = $this->column->getType();
85
-        $normalizedType = TDBMDaoGenerator::dbalTypeToPhpType($type);
86
-
87
-        $columnGetterName = $this->getGetterName();
88
-        $columnSetterName = $this->getSetterName();
89
-
90
-        if ($normalizedType == "\\DateTimeInterface") {
91
-            $castTo = "\\DateTimeInterface ";
92
-        } else {
93
-            $castTo = "";
94
-        }
95
-
96
-        $getterAndSetterCode = '    /**
15
+	/**
16
+	 * @var Column
17
+	 */
18
+	private $column;
19
+
20
+
21
+	public function __construct(Table $table, Column $column) {
22
+		parent::__construct($table);
23
+		$this->table = $table;
24
+		$this->column = $column;
25
+	}
26
+
27
+	/**
28
+	 * Returns the foreignkey the column is part of, if any. null otherwise.
29
+	 *
30
+	 * @param Column $column
31
+	 * @return ForeignKeyConstraint|null
32
+	 */
33
+	public function getForeignKey() {
34
+		return false;
35
+	}
36
+
37
+	/**
38
+	 * Returns the param annotation for this property (useful for constructor).
39
+	 *
40
+	 * @return string
41
+	 */
42
+	public function getParamAnnotation() {
43
+		$className = $this->getClassName();
44
+		$paramType = $className ?: TDBMDaoGenerator::dbalTypeToPhpType($this->column->getType());
45
+
46
+		$str = "     * @param %s %s";
47
+		return sprintf($str, $paramType, $this->getVariableName());
48
+	}
49
+
50
+	public function getUpperCamelCaseName() {
51
+		return TDBMDaoGenerator::toCamelCase($this->column->getName());
52
+	}
53
+
54
+	/**
55
+	 * Returns the name of the class linked to this property or null if this is not a foreign key
56
+	 * @return null|string
57
+	 */
58
+	public function getClassName() {
59
+		return null;
60
+	}
61
+
62
+	/**
63
+	 * Returns true if the property is compulsory (and therefore should be fetched in the constructor).
64
+	 * @return bool
65
+	 */
66
+	public function isCompulsory() {
67
+		return $this->column->getNotnull() && !$this->column->getAutoincrement();
68
+	}
69
+
70
+	/**
71
+	 * Returns true if the property is the primary key
72
+	 * @return bool
73
+	 */
74
+	public function isPrimaryKey() {
75
+		return in_array($this->column->getName(), $this->table->getPrimaryKeyColumns());
76
+	}
77
+
78
+	/**
79
+	 * Returns the PHP code for getters and setters
80
+	 * @return string
81
+	 */
82
+	public function getGetterSetterCode() {
83
+
84
+		$type = $this->column->getType();
85
+		$normalizedType = TDBMDaoGenerator::dbalTypeToPhpType($type);
86
+
87
+		$columnGetterName = $this->getGetterName();
88
+		$columnSetterName = $this->getSetterName();
89
+
90
+		if ($normalizedType == "\\DateTimeInterface") {
91
+			$castTo = "\\DateTimeInterface ";
92
+		} else {
93
+			$castTo = "";
94
+		}
95
+
96
+		$getterAndSetterCode = '    /**
97 97
      * The getter for the "%s" column.
98 98
      *
99 99
      * @return %s
@@ -112,23 +112,23 @@  discard block
 block discarded – undo
112 112
     }
113 113
 
114 114
 ';
115
-        return sprintf($getterAndSetterCode,
116
-            // Getter
117
-            $this->column->getName(),
118
-            $normalizedType,
119
-            $columnGetterName,
120
-            var_export($this->column->getName(), true),
121
-            var_export($this->table->getName(), true),
122
-            // Setter
123
-            $this->column->getName(),
124
-            $normalizedType,
125
-            $this->column->getName(),
126
-            $columnSetterName,
127
-            $castTo,
128
-            $this->column->getName(),
129
-            var_export($this->column->getName(), true),
130
-            $this->column->getName(),
131
-            var_export($this->table->getName(), true)
132
-        );
133
-    }
115
+		return sprintf($getterAndSetterCode,
116
+			// Getter
117
+			$this->column->getName(),
118
+			$normalizedType,
119
+			$columnGetterName,
120
+			var_export($this->column->getName(), true),
121
+			var_export($this->table->getName(), true),
122
+			// Setter
123
+			$this->column->getName(),
124
+			$normalizedType,
125
+			$this->column->getName(),
126
+			$columnSetterName,
127
+			$castTo,
128
+			$this->column->getName(),
129
+			var_export($this->column->getName(), true),
130
+			$this->column->getName(),
131
+			var_export($this->table->getName(), true)
132
+		);
133
+	}
134 134
 }
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Utils/TDBMDaoGenerator.php 5 patches
Doc Comments   +11 added lines, -6 removed lines patch added patch discarded remove patch
@@ -46,7 +46,6 @@  discard block
 block discarded – undo
46 46
     /**
47 47
      * Constructor.
48 48
      *
49
-     * @param Connection $dbConnection The connection to the database.
50 49
      */
51 50
     public function __construct(SchemaAnalyzer $schemaAnalyzer, Schema $schema, TDBMSchemaAnalyzer $tdbmSchemaAnalyzer) {
52 51
         $this->schemaAnalyzer = $schemaAnalyzer;
@@ -99,6 +98,9 @@  discard block
 block discarded – undo
99 98
      * Generates in one method call the daos and the beans for one table.
100 99
      * 
101 100
      * @param $tableName
101
+     * @param string $daonamespace
102
+     * @param string $beannamespace
103
+     * @param boolean $storeInUtc
102 104
      */
103 105
     public function generateDaoAndBean(Table $table, $daonamespace, $beannamespace, ClassNameMapper $classNameMapper, $storeInUtc) {
104 106
 		$tableName = $table->getName();
@@ -134,7 +136,7 @@  discard block
 block discarded – undo
134 136
     /**
135 137
      * Returns the name of the base bean class from the table name.
136 138
      * 
137
-     * @param $tableName
139
+     * @param string $tableName
138 140
      * @return string
139 141
      */
140 142
     public static function getBaseBeanNameFromTableName($tableName) {
@@ -144,7 +146,7 @@  discard block
 block discarded – undo
144 146
     /**
145 147
      * Returns the name of the base DAO class from the table name.
146 148
      *
147
-     * @param $tableName
149
+     * @param string $tableName
148 150
      * @return string
149 151
      */
150 152
     public static function getBaseDaoNameFromTableName($tableName) {
@@ -156,7 +158,7 @@  discard block
 block discarded – undo
156 158
      *
157 159
      * @param string $className The name of the class
158 160
      * @param string $baseClassName The name of the base class which will be extended (name only, no directory)
159
-     * @param string $tableName The name of the table
161
+     * @param string $table The name of the table
160 162
      * @param string $beannamespace The namespace of the bean
161 163
      * @param ClassNameMapper $classNameMapper
162 164
      * @throws TDBMException
@@ -214,9 +216,10 @@  discard block
 block discarded – undo
214 216
     /**
215 217
      * Writes the PHP bean DAO with simple functions to create/get/save objects.
216 218
      *
217
-     * @param string $fileName The file that will be written (without the directory)
218 219
      * @param string $className The name of the class
219
-     * @param string $tableName The name of the table
220
+     * @param string $table The name of the table
221
+     * @param string $baseClassName
222
+     * @param string $beanClassName
220 223
      */
221 224
     public function generateDao($className, $baseClassName, $beanClassName, Table $table, $daonamespace, $beannamespace, ClassNameMapper $classNameMapper) {
222 225
         $tableName = $table->getName();
@@ -458,6 +461,8 @@  discard block
 block discarded – undo
458 461
      * Generates the factory bean.
459 462
      * 
460 463
      * @param Table[] $tableList
464
+     * @param string $daoFactoryClassName
465
+     * @param string $daoNamespace
461 466
      */
462 467
     private function generateFactory(array $tableList, $daoFactoryClassName, $daoNamespace, ClassNameMapper $classNameMapper) {
463 468
         // For each table, let's write a property.
Please login to merge, or discard this patch.
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,6 @@
 block discarded – undo
2 2
 namespace Mouf\Database\TDBM\Utils;
3 3
 
4 4
 use Doctrine\DBAL\Driver\Connection;
5
-use Doctrine\DBAL\Schema\Column;
6
-use Doctrine\DBAL\Schema\ForeignKeyConstraint;
7 5
 use Doctrine\DBAL\Schema\Schema;
8 6
 use Doctrine\DBAL\Schema\Table;
9 7
 use Doctrine\DBAL\Types\Type;
Please login to merge, or discard this patch.
Indentation   +372 added lines, -372 removed lines patch added patch discarded remove patch
@@ -19,178 +19,178 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class TDBMDaoGenerator {
21 21
 
22
-    /**
23
-     * 
24
-     * @var SchemaAnalyzer
25
-     */
26
-    private $schemaAnalyzer;
27
-
28
-    /**
29
-     *
30
-     * @var Schema
31
-     */
32
-    private $schema;
33
-
34
-    /**
35
-     * The root directory of the project.
36
-     *
37
-     * @var string
38
-     */
39
-    private $rootPath;
40
-
41
-    /**
42
-     * @var TDBMSchemaAnalyzer
43
-     */
44
-    private $tdbmSchemaAnalyzer;
45
-
46
-    /**
47
-     * Constructor.
48
-     *
49
-     * @param Connection $dbConnection The connection to the database.
50
-     */
51
-    public function __construct(SchemaAnalyzer $schemaAnalyzer, Schema $schema, TDBMSchemaAnalyzer $tdbmSchemaAnalyzer) {
52
-        $this->schemaAnalyzer = $schemaAnalyzer;
53
-        $this->schema = $schema;
54
-        $this->tdbmSchemaAnalyzer = $tdbmSchemaAnalyzer;
55
-        $this->rootPath = __DIR__."/../../../../../../../../";
56
-    }
57
-
58
-    /**
59
-     * Generates all the daos and beans.
60
-     *
61
-     * @param string $daoFactoryClassName The classe name of the DAO factory
62
-     * @param string $daonamespace The namespace for the DAOs, without trailing \
63
-     * @param string $beannamespace The Namespace for the beans, without trailing \
64
-     * @param bool $storeInUtc If the generated daos should store the date in UTC timezone instead of user's timezone.
65
-     * @return \string[] the list of tables
66
-     * @throws TDBMException
67
-     */
68
-    public function generateAllDaosAndBeans($daoFactoryClassName, $daonamespace, $beannamespace, $storeInUtc) {
69
-        // TODO: extract ClassNameMapper in its own package!
70
-        $classNameMapper = ClassNameMapper::createFromComposerFile($this->rootPath.'composer.json');
71
-
72
-        // TODO: check that no class name ends with "Base". Otherwise, there will be name clash.
73
-
74
-        $tableList = $this->schema->getTables();
75
-
76
-        // Remove all beans and daos from junction tables
77
-        $junctionTables = $this->schemaAnalyzer->detectJunctionTables();
78
-        $junctionTableNames = array_map(function(Table $table) {
79
-            return $table->getName();
80
-        }, $junctionTables);
81
-
82
-        $tableList = array_filter($tableList, function(Table $table) use ($junctionTableNames) {
83
-            return !in_array($table->getName(), $junctionTableNames);
84
-        });
85
-
86
-        foreach ($tableList as $table) {
87
-            $this->generateDaoAndBean($table, $daonamespace, $beannamespace, $classNameMapper, $storeInUtc);
88
-        }
22
+	/**
23
+	 * 
24
+	 * @var SchemaAnalyzer
25
+	 */
26
+	private $schemaAnalyzer;
27
+
28
+	/**
29
+	 *
30
+	 * @var Schema
31
+	 */
32
+	private $schema;
33
+
34
+	/**
35
+	 * The root directory of the project.
36
+	 *
37
+	 * @var string
38
+	 */
39
+	private $rootPath;
40
+
41
+	/**
42
+	 * @var TDBMSchemaAnalyzer
43
+	 */
44
+	private $tdbmSchemaAnalyzer;
45
+
46
+	/**
47
+	 * Constructor.
48
+	 *
49
+	 * @param Connection $dbConnection The connection to the database.
50
+	 */
51
+	public function __construct(SchemaAnalyzer $schemaAnalyzer, Schema $schema, TDBMSchemaAnalyzer $tdbmSchemaAnalyzer) {
52
+		$this->schemaAnalyzer = $schemaAnalyzer;
53
+		$this->schema = $schema;
54
+		$this->tdbmSchemaAnalyzer = $tdbmSchemaAnalyzer;
55
+		$this->rootPath = __DIR__."/../../../../../../../../";
56
+	}
57
+
58
+	/**
59
+	 * Generates all the daos and beans.
60
+	 *
61
+	 * @param string $daoFactoryClassName The classe name of the DAO factory
62
+	 * @param string $daonamespace The namespace for the DAOs, without trailing \
63
+	 * @param string $beannamespace The Namespace for the beans, without trailing \
64
+	 * @param bool $storeInUtc If the generated daos should store the date in UTC timezone instead of user's timezone.
65
+	 * @return \string[] the list of tables
66
+	 * @throws TDBMException
67
+	 */
68
+	public function generateAllDaosAndBeans($daoFactoryClassName, $daonamespace, $beannamespace, $storeInUtc) {
69
+		// TODO: extract ClassNameMapper in its own package!
70
+		$classNameMapper = ClassNameMapper::createFromComposerFile($this->rootPath.'composer.json');
71
+
72
+		// TODO: check that no class name ends with "Base". Otherwise, there will be name clash.
73
+
74
+		$tableList = $this->schema->getTables();
75
+
76
+		// Remove all beans and daos from junction tables
77
+		$junctionTables = $this->schemaAnalyzer->detectJunctionTables();
78
+		$junctionTableNames = array_map(function(Table $table) {
79
+			return $table->getName();
80
+		}, $junctionTables);
81
+
82
+		$tableList = array_filter($tableList, function(Table $table) use ($junctionTableNames) {
83
+			return !in_array($table->getName(), $junctionTableNames);
84
+		});
85
+
86
+		foreach ($tableList as $table) {
87
+			$this->generateDaoAndBean($table, $daonamespace, $beannamespace, $classNameMapper, $storeInUtc);
88
+		}
89 89
         
90
-        $this->generateFactory($tableList, $daoFactoryClassName, $daonamespace, $classNameMapper);
90
+		$this->generateFactory($tableList, $daoFactoryClassName, $daonamespace, $classNameMapper);
91 91
 
92
-        // Ok, let's return the list of all tables.
93
-        // These will be used by the calling script to create Mouf instances.
92
+		// Ok, let's return the list of all tables.
93
+		// These will be used by the calling script to create Mouf instances.
94 94
         
95
-        return array_map(function(Table $table) { return $table->getName(); },$tableList);
96
-    }
95
+		return array_map(function(Table $table) { return $table->getName(); },$tableList);
96
+	}
97 97
     
98
-    /**
99
-     * Generates in one method call the daos and the beans for one table.
100
-     * 
101
-     * @param $tableName
102
-     */
103
-    public function generateDaoAndBean(Table $table, $daonamespace, $beannamespace, ClassNameMapper $classNameMapper, $storeInUtc) {
98
+	/**
99
+	 * Generates in one method call the daos and the beans for one table.
100
+	 * 
101
+	 * @param $tableName
102
+	 */
103
+	public function generateDaoAndBean(Table $table, $daonamespace, $beannamespace, ClassNameMapper $classNameMapper, $storeInUtc) {
104 104
 		$tableName = $table->getName();
105
-        $daoName = $this->getDaoNameFromTableName($tableName);
106
-        $beanName = $this->getBeanNameFromTableName($tableName);
107
-        $baseBeanName = $this->getBaseBeanNameFromTableName($tableName);
108
-        $baseDaoName = $this->getBaseDaoNameFromTableName($tableName);
109
-
110
-        $this->generateBean($beanName, $baseBeanName, $table, $beannamespace, $classNameMapper, $storeInUtc);
111
-        $this->generateDao($daoName, $baseDaoName, $beanName, $table, $daonamespace, $beannamespace, $classNameMapper);
112
-    }
105
+		$daoName = $this->getDaoNameFromTableName($tableName);
106
+		$beanName = $this->getBeanNameFromTableName($tableName);
107
+		$baseBeanName = $this->getBaseBeanNameFromTableName($tableName);
108
+		$baseDaoName = $this->getBaseDaoNameFromTableName($tableName);
109
+
110
+		$this->generateBean($beanName, $baseBeanName, $table, $beannamespace, $classNameMapper, $storeInUtc);
111
+		$this->generateDao($daoName, $baseDaoName, $beanName, $table, $daonamespace, $beannamespace, $classNameMapper);
112
+	}
113 113
     
114
-    /**
115
-     * Returns the name of the bean class from the table name.
116
-     * 
117
-     * @param $tableName
118
-     * @return string
119
-     */
120
-    public static function getBeanNameFromTableName($tableName) {
121
-        return TDBMDaoGenerator::toSingular(TDBMDaoGenerator::toCamelCase($tableName))."Bean";
122
-    }
114
+	/**
115
+	 * Returns the name of the bean class from the table name.
116
+	 * 
117
+	 * @param $tableName
118
+	 * @return string
119
+	 */
120
+	public static function getBeanNameFromTableName($tableName) {
121
+		return TDBMDaoGenerator::toSingular(TDBMDaoGenerator::toCamelCase($tableName))."Bean";
122
+	}
123 123
     
124
-    /**
125
-     * Returns the name of the DAO class from the table name.
126
-     * 
127
-     * @param $tableName
128
-     * @return string
129
-     */
130
-    public static function getDaoNameFromTableName($tableName) {
131
-        return TDBMDaoGenerator::toSingular(TDBMDaoGenerator::toCamelCase($tableName))."Dao";
132
-    }
124
+	/**
125
+	 * Returns the name of the DAO class from the table name.
126
+	 * 
127
+	 * @param $tableName
128
+	 * @return string
129
+	 */
130
+	public static function getDaoNameFromTableName($tableName) {
131
+		return TDBMDaoGenerator::toSingular(TDBMDaoGenerator::toCamelCase($tableName))."Dao";
132
+	}
133 133
     
134
-    /**
135
-     * Returns the name of the base bean class from the table name.
136
-     * 
137
-     * @param $tableName
138
-     * @return string
139
-     */
140
-    public static function getBaseBeanNameFromTableName($tableName) {
141
-        return TDBMDaoGenerator::toSingular(TDBMDaoGenerator::toCamelCase($tableName))."BaseBean";
142
-    }
143
-
144
-    /**
145
-     * Returns the name of the base DAO class from the table name.
146
-     *
147
-     * @param $tableName
148
-     * @return string
149
-     */
150
-    public static function getBaseDaoNameFromTableName($tableName) {
151
-        return TDBMDaoGenerator::toSingular(TDBMDaoGenerator::toCamelCase($tableName))."BaseDao";
152
-    }
153
-
154
-    /**
155
-     * Writes the PHP bean file with all getters and setters from the table passed in parameter.
156
-     *
157
-     * @param string $className The name of the class
158
-     * @param string $baseClassName The name of the base class which will be extended (name only, no directory)
159
-     * @param string $tableName The name of the table
160
-     * @param string $beannamespace The namespace of the bean
161
-     * @param ClassNameMapper $classNameMapper
162
-     * @throws TDBMException
163
-     */
164
-    public function generateBean($className, $baseClassName, Table $table, $beannamespace, ClassNameMapper $classNameMapper, $storeInUtc) {
165
-
166
-        $beanDescriptor = new BeanDescriptor($table, $this->schemaAnalyzer, $this->schema);
167
-
168
-        $str = $beanDescriptor->generatePhpCode($beannamespace);
169
-
170
-        $possibleBaseFileNames = $classNameMapper->getPossibleFileNames($beannamespace."\\".$baseClassName);
171
-        if (!$possibleBaseFileNames) {
172
-            throw new TDBMException('Sorry, autoload namespace issue. The class "'.$beannamespace."\\".$baseClassName.'" is not autoloadable.');
173
-        }
174
-        $possibleBaseFileName = $this->rootPath.$possibleBaseFileNames[0];
175
-
176
-        $this->ensureDirectoryExist($possibleBaseFileName);
177
-        file_put_contents($possibleBaseFileName, $str);
178
-        @chmod($possibleBaseFileName, 0664);
179
-
180
-
181
-
182
-        $possibleFileNames = $classNameMapper->getPossibleFileNames($beannamespace."\\".$className);
183
-        if (!$possibleFileNames) {
184
-            // @codeCoverageIgnoreStart
185
-            throw new TDBMException('Sorry, autoload namespace issue. The class "'.$beannamespace."\\".$className.'" is not autoloadable.');
186
-            // @codeCoverageIgnoreEnd
187
-        }
188
-        $possibleFileName = $this->rootPath.$possibleFileNames[0];
189
-
190
-        if (!file_exists($possibleFileName)) {
191
-            $tableName = $table->getName();
192
-
193
-            $str = "<?php
134
+	/**
135
+	 * Returns the name of the base bean class from the table name.
136
+	 * 
137
+	 * @param $tableName
138
+	 * @return string
139
+	 */
140
+	public static function getBaseBeanNameFromTableName($tableName) {
141
+		return TDBMDaoGenerator::toSingular(TDBMDaoGenerator::toCamelCase($tableName))."BaseBean";
142
+	}
143
+
144
+	/**
145
+	 * Returns the name of the base DAO class from the table name.
146
+	 *
147
+	 * @param $tableName
148
+	 * @return string
149
+	 */
150
+	public static function getBaseDaoNameFromTableName($tableName) {
151
+		return TDBMDaoGenerator::toSingular(TDBMDaoGenerator::toCamelCase($tableName))."BaseDao";
152
+	}
153
+
154
+	/**
155
+	 * Writes the PHP bean file with all getters and setters from the table passed in parameter.
156
+	 *
157
+	 * @param string $className The name of the class
158
+	 * @param string $baseClassName The name of the base class which will be extended (name only, no directory)
159
+	 * @param string $tableName The name of the table
160
+	 * @param string $beannamespace The namespace of the bean
161
+	 * @param ClassNameMapper $classNameMapper
162
+	 * @throws TDBMException
163
+	 */
164
+	public function generateBean($className, $baseClassName, Table $table, $beannamespace, ClassNameMapper $classNameMapper, $storeInUtc) {
165
+
166
+		$beanDescriptor = new BeanDescriptor($table, $this->schemaAnalyzer, $this->schema);
167
+
168
+		$str = $beanDescriptor->generatePhpCode($beannamespace);
169
+
170
+		$possibleBaseFileNames = $classNameMapper->getPossibleFileNames($beannamespace."\\".$baseClassName);
171
+		if (!$possibleBaseFileNames) {
172
+			throw new TDBMException('Sorry, autoload namespace issue. The class "'.$beannamespace."\\".$baseClassName.'" is not autoloadable.');
173
+		}
174
+		$possibleBaseFileName = $this->rootPath.$possibleBaseFileNames[0];
175
+
176
+		$this->ensureDirectoryExist($possibleBaseFileName);
177
+		file_put_contents($possibleBaseFileName, $str);
178
+		@chmod($possibleBaseFileName, 0664);
179
+
180
+
181
+
182
+		$possibleFileNames = $classNameMapper->getPossibleFileNames($beannamespace."\\".$className);
183
+		if (!$possibleFileNames) {
184
+			// @codeCoverageIgnoreStart
185
+			throw new TDBMException('Sorry, autoload namespace issue. The class "'.$beannamespace."\\".$className.'" is not autoloadable.');
186
+			// @codeCoverageIgnoreEnd
187
+		}
188
+		$possibleFileName = $this->rootPath.$possibleFileNames[0];
189
+
190
+		if (!file_exists($possibleFileName)) {
191
+			$tableName = $table->getName();
192
+
193
+			$str = "<?php
194 194
 /*
195 195
  * This file has been automatically generated by TDBM.
196 196
  * You can edit this file as it will not be overwritten.
@@ -205,44 +205,44 @@  discard block
 block discarded – undo
205 205
 {
206 206
 
207 207
 }";
208
-            $this->ensureDirectoryExist($possibleFileName);
209
-            file_put_contents($possibleFileName ,$str);
210
-            @chmod($possibleFileName, 0664);
211
-        }
212
-    }
213
-
214
-    /**
215
-     * Writes the PHP bean DAO with simple functions to create/get/save objects.
216
-     *
217
-     * @param string $fileName The file that will be written (without the directory)
218
-     * @param string $className The name of the class
219
-     * @param string $tableName The name of the table
220
-     */
221
-    public function generateDao($className, $baseClassName, $beanClassName, Table $table, $daonamespace, $beannamespace, ClassNameMapper $classNameMapper) {
222
-        $tableName = $table->getName();
223
-        $primaryKeyColumns = $table->getPrimaryKeyColumns();
224
-
225
-        $defaultSort = null;
226
-        foreach ($table->getColumns() as $column) {
227
-            $comments = $column->getComment();
228
-            $matches = array();
229
-            if (preg_match('/@defaultSort(\((desc|asc)\))*/', $comments, $matches) != 0){
230
-                $defaultSort = $data['column_name'];
231
-                if (count($matches == 3)){
232
-                    $defaultSortDirection = $matches[2];
233
-                }else{
234
-                    $defaultSortDirection = 'ASC';
235
-                }
236
-            }
237
-        }
208
+			$this->ensureDirectoryExist($possibleFileName);
209
+			file_put_contents($possibleFileName ,$str);
210
+			@chmod($possibleFileName, 0664);
211
+		}
212
+	}
213
+
214
+	/**
215
+	 * Writes the PHP bean DAO with simple functions to create/get/save objects.
216
+	 *
217
+	 * @param string $fileName The file that will be written (without the directory)
218
+	 * @param string $className The name of the class
219
+	 * @param string $tableName The name of the table
220
+	 */
221
+	public function generateDao($className, $baseClassName, $beanClassName, Table $table, $daonamespace, $beannamespace, ClassNameMapper $classNameMapper) {
222
+		$tableName = $table->getName();
223
+		$primaryKeyColumns = $table->getPrimaryKeyColumns();
224
+
225
+		$defaultSort = null;
226
+		foreach ($table->getColumns() as $column) {
227
+			$comments = $column->getComment();
228
+			$matches = array();
229
+			if (preg_match('/@defaultSort(\((desc|asc)\))*/', $comments, $matches) != 0){
230
+				$defaultSort = $data['column_name'];
231
+				if (count($matches == 3)){
232
+					$defaultSortDirection = $matches[2];
233
+				}else{
234
+					$defaultSortDirection = 'ASC';
235
+				}
236
+			}
237
+		}
238 238
 
239
-        // FIXME: lowercase tables with _ in the name should work!
240
-        $tableCamel = self::toSingular(self::toCamelCase($tableName));
239
+		// FIXME: lowercase tables with _ in the name should work!
240
+		$tableCamel = self::toSingular(self::toCamelCase($tableName));
241 241
         
242
-        $beanClassWithoutNameSpace = $beanClassName;
243
-        $beanClassName = $beannamespace."\\".$beanClassName;
242
+		$beanClassWithoutNameSpace = $beanClassName;
243
+		$beanClassName = $beannamespace."\\".$beanClassName;
244 244
         
245
-        $str = "<?php
245
+		$str = "<?php
246 246
 
247 247
 /*
248 248
  * This file has been automatically generated by TDBM.
@@ -329,9 +329,9 @@  discard block
 block discarded – undo
329 329
     }
330 330
     ";
331 331
 
332
-        if (count($primaryKeyColumns) === 1) {
333
-            $primaryKeyColumn = $primaryKeyColumns[0];
334
-            $str .= "
332
+		if (count($primaryKeyColumns) === 1) {
333
+			$primaryKeyColumn = $primaryKeyColumns[0];
334
+			$str .= "
335 335
     /**
336 336
      * Get $beanClassWithoutNameSpace specified by its ID (its primary key)
337 337
      * If the primary key does not exist, an exception is thrown.
@@ -346,8 +346,8 @@  discard block
 block discarded – undo
346 346
         return \$this->tdbmService->findObjectByPk('$tableName', ['$primaryKeyColumn' => \$id], [], \$lazyLoading);
347 347
     }
348 348
     ";
349
-        }
350
-        $str .= "
349
+		}
350
+		$str .= "
351 351
     /**
352 352
      * Deletes the $beanClassWithoutNameSpace passed in parameter.
353 353
      *
@@ -407,29 +407,29 @@  discard block
 block discarded – undo
407 407
 }
408 408
 ";
409 409
 
410
-        $possibleBaseFileNames = $classNameMapper->getPossibleFileNames($daonamespace."\\".$baseClassName);
411
-        if (!$possibleBaseFileNames) {
412
-            // @codeCoverageIgnoreStart
413
-            throw new TDBMException('Sorry, autoload namespace issue. The class "'.$baseClassName.'" is not autoloadable.');
414
-            // @codeCoverageIgnoreEnd
415
-        }
416
-        $possibleBaseFileName = $this->rootPath.$possibleBaseFileNames[0];
417
-
418
-        $this->ensureDirectoryExist($possibleBaseFileName);
419
-        file_put_contents($possibleBaseFileName ,$str);
420
-        @chmod($possibleBaseFileName, 0664);
421
-
422
-        $possibleFileNames = $classNameMapper->getPossibleFileNames($daonamespace."\\".$className);
423
-        if (!$possibleFileNames) {
424
-            // @codeCoverageIgnoreStart
425
-            throw new TDBMException('Sorry, autoload namespace issue. The class "'.$className.'" is not autoloadable.');
426
-            // @codeCoverageIgnoreEnd
427
-        }
428
-        $possibleFileName = $this->rootPath.$possibleFileNames[0];
410
+		$possibleBaseFileNames = $classNameMapper->getPossibleFileNames($daonamespace."\\".$baseClassName);
411
+		if (!$possibleBaseFileNames) {
412
+			// @codeCoverageIgnoreStart
413
+			throw new TDBMException('Sorry, autoload namespace issue. The class "'.$baseClassName.'" is not autoloadable.');
414
+			// @codeCoverageIgnoreEnd
415
+		}
416
+		$possibleBaseFileName = $this->rootPath.$possibleBaseFileNames[0];
417
+
418
+		$this->ensureDirectoryExist($possibleBaseFileName);
419
+		file_put_contents($possibleBaseFileName ,$str);
420
+		@chmod($possibleBaseFileName, 0664);
421
+
422
+		$possibleFileNames = $classNameMapper->getPossibleFileNames($daonamespace."\\".$className);
423
+		if (!$possibleFileNames) {
424
+			// @codeCoverageIgnoreStart
425
+			throw new TDBMException('Sorry, autoload namespace issue. The class "'.$className.'" is not autoloadable.');
426
+			// @codeCoverageIgnoreEnd
427
+		}
428
+		$possibleFileName = $this->rootPath.$possibleFileNames[0];
429 429
         
430
-        // Now, let's generate the "editable" class
431
-        if (!file_exists($possibleFileName)) {
432
-            $str = "<?php
430
+		// Now, let's generate the "editable" class
431
+		if (!file_exists($possibleFileName)) {
432
+			$str = "<?php
433 433
 
434 434
 /*
435 435
  * This file has been automatically generated by TDBM.
@@ -446,23 +446,23 @@  discard block
 block discarded – undo
446 446
 
447 447
 }
448 448
 ";
449
-            $this->ensureDirectoryExist($possibleFileName);
450
-            file_put_contents($possibleFileName ,$str);
451
-            @chmod($possibleFileName, 0664);
452
-        }
453
-    }
449
+			$this->ensureDirectoryExist($possibleFileName);
450
+			file_put_contents($possibleFileName ,$str);
451
+			@chmod($possibleFileName, 0664);
452
+		}
453
+	}
454 454
 
455 455
 
456 456
 
457
-    /**
458
-     * Generates the factory bean.
459
-     * 
460
-     * @param Table[] $tableList
461
-     */
462
-    private function generateFactory(array $tableList, $daoFactoryClassName, $daoNamespace, ClassNameMapper $classNameMapper) {
463
-        // For each table, let's write a property.
457
+	/**
458
+	 * Generates the factory bean.
459
+	 * 
460
+	 * @param Table[] $tableList
461
+	 */
462
+	private function generateFactory(array $tableList, $daoFactoryClassName, $daoNamespace, ClassNameMapper $classNameMapper) {
463
+		// For each table, let's write a property.
464 464
         
465
-        $str = "<?php
465
+		$str = "<?php
466 466
 
467 467
 /*
468 468
  * This file has been automatically generated by TDBM.
@@ -479,12 +479,12 @@  discard block
 block discarded – undo
479 479
 {
480 480
 ";
481 481
 
482
-        foreach ($tableList as $table) {
483
-            $tableName = $table->getName();
484
-            $daoClassName = $this->getDaoNameFromTableName($tableName);
485
-            $daoInstanceName = self::toVariableName($daoClassName);
482
+		foreach ($tableList as $table) {
483
+			$tableName = $table->getName();
484
+			$daoClassName = $this->getDaoNameFromTableName($tableName);
485
+			$daoInstanceName = self::toVariableName($daoClassName);
486 486
             
487
-            $str .= '    /**
487
+			$str .= '    /**
488 488
      * @var '.$daoClassName.'
489 489
      */
490 490
     private $'.$daoInstanceName.';
@@ -509,141 +509,141 @@  discard block
 block discarded – undo
509 509
     }
510 510
     
511 511
 ';
512
-        }
512
+		}
513 513
         
514 514
         
515
-        $str .= '
515
+		$str .= '
516 516
 }
517 517
 ';
518 518
 
519
-        $possibleFileNames = $classNameMapper->getPossibleFileNames($daoNamespace."\\".$daoFactoryClassName);
520
-        if (!$possibleFileNames) {
521
-            throw new TDBMException('Sorry, autoload namespace issue. The class "'.$daoNamespace."\\".$daoFactoryClassName.'" is not autoloadable.');
522
-        }
523
-        $possibleFileName = $this->rootPath.$possibleFileNames[0];
524
-
525
-        $this->ensureDirectoryExist($possibleFileName);
526
-        file_put_contents($possibleFileName ,$str);
527
-    }
528
-
529
-    /**
530
-     * Transforms a string to camelCase (except the first letter will be uppercase too).
531
-     * Underscores and spaces are removed and the first letter after the underscore is uppercased.
532
-     * 
533
-     * @param $str string
534
-     * @return string
535
-     */
536
-    public static function toCamelCase($str) {
537
-        $str = strtoupper(substr($str,0,1)).substr($str,1);
538
-        while (true) {
539
-            if (strpos($str, "_") === false && strpos($str, " ") === false) {
540
-                break;
519
+		$possibleFileNames = $classNameMapper->getPossibleFileNames($daoNamespace."\\".$daoFactoryClassName);
520
+		if (!$possibleFileNames) {
521
+			throw new TDBMException('Sorry, autoload namespace issue. The class "'.$daoNamespace."\\".$daoFactoryClassName.'" is not autoloadable.');
522
+		}
523
+		$possibleFileName = $this->rootPath.$possibleFileNames[0];
524
+
525
+		$this->ensureDirectoryExist($possibleFileName);
526
+		file_put_contents($possibleFileName ,$str);
527
+	}
528
+
529
+	/**
530
+	 * Transforms a string to camelCase (except the first letter will be uppercase too).
531
+	 * Underscores and spaces are removed and the first letter after the underscore is uppercased.
532
+	 * 
533
+	 * @param $str string
534
+	 * @return string
535
+	 */
536
+	public static function toCamelCase($str) {
537
+		$str = strtoupper(substr($str,0,1)).substr($str,1);
538
+		while (true) {
539
+			if (strpos($str, "_") === false && strpos($str, " ") === false) {
540
+				break;
541 541
 			}
542 542
                 
543
-            $pos = strpos($str, "_");
544
-            if ($pos === false) {
545
-                $pos = strpos($str, " ");
546
-            }
547
-            $before = substr($str,0,$pos);
548
-            $after = substr($str,$pos+1);
549
-            $str = $before.strtoupper(substr($after,0,1)).substr($after,1);
550
-        }
551
-        return $str;
552
-    }
543
+			$pos = strpos($str, "_");
544
+			if ($pos === false) {
545
+				$pos = strpos($str, " ");
546
+			}
547
+			$before = substr($str,0,$pos);
548
+			$after = substr($str,$pos+1);
549
+			$str = $before.strtoupper(substr($after,0,1)).substr($after,1);
550
+		}
551
+		return $str;
552
+	}
553 553
     
554
-    /**
555
-     * Tries to put string to the singular form (if it is plural).
556
-     * We assume the table names are in english.
557
-     *
558
-     * @param $str string
559
-     * @return string
560
-     */
561
-    public static function toSingular($str) {
562
-        return \ICanBoogie\singularize($str, "en");
563
-    }
554
+	/**
555
+	 * Tries to put string to the singular form (if it is plural).
556
+	 * We assume the table names are in english.
557
+	 *
558
+	 * @param $str string
559
+	 * @return string
560
+	 */
561
+	public static function toSingular($str) {
562
+		return \ICanBoogie\singularize($str, "en");
563
+	}
564 564
     
565
-    /**
566
-     * Put the first letter of the string in lower case.
567
-     * Very useful to transform a class name into a variable name.
568
-     * 
569
-     * @param $str string
570
-     * @return string
571
-     */
572
-    public static function toVariableName($str) {
573
-        return strtolower(substr($str, 0, 1)).substr($str, 1);
574
-    }
575
-
576
-    /**
577
-     * Ensures the file passed in parameter can be written in its directory.
578
-     * @param string $fileName
579
-     */
580
-    private function ensureDirectoryExist($fileName) {
581
-        $dirName = dirname($fileName);
582
-        if (!file_exists($dirName)) {
583
-            $old = umask(0);
584
-            $result = mkdir($dirName, 0775, true);
585
-            umask($old);
586
-            if ($result == false) {
587
-                echo "Unable to create directory: ".$dirName.".";
588
-                exit;
589
-            }
590
-        }
591
-    }
592
-
593
-    /**
594
-     * @param string $rootPath
595
-     */
596
-    public function setRootPath($rootPath)
597
-    {
598
-        $this->rootPath = $rootPath;
599
-    }
600
-
601
-    /**
602
-     * Transforms a DBAL type into a PHP type (for PHPDoc purpose)
603
-     *
604
-     * @param Type $type The DBAL type
605
-     * @return string The PHP type
606
-     */
607
-    public static function dbalTypeToPhpType(Type $type) {
608
-        $map = [
609
-            Type::TARRAY => 'array',
610
-            Type::SIMPLE_ARRAY => 'array',
611
-            Type::JSON_ARRAY => 'array',
612
-            Type::BIGINT => 'string',
613
-            Type::BOOLEAN => 'bool',
614
-            Type::DATETIME => '\DateTimeInterface',
615
-            Type::DATETIMETZ => '\DateTimeInterface',
616
-            Type::DATE => '\DateTimeInterface',
617
-            Type::TIME => '\DateTimeInterface',
618
-            Type::DECIMAL => 'float',
619
-            Type::INTEGER => 'int',
620
-            Type::OBJECT => 'string',
621
-            Type::SMALLINT => 'int',
622
-            Type::STRING => 'string',
623
-            Type::TEXT => 'string',
624
-            Type::BINARY => 'string',
625
-            Type::BLOB => 'string',
626
-            Type::FLOAT => 'float',
627
-            Type::GUID => 'string'
628
-        ];
629
-
630
-        return isset($map[$type->getName()])?$map[$type->getName()]:$type->getName();
631
-    }
632
-
633
-    /**
634
-     *
635
-     * @param string $beanNamespace
636
-     * @return \string[] Returns a map mapping table name to beans name
637
-     */
638
-    public function buildTableToBeanMap($beanNamespace) {
639
-        $tableToBeanMap = [];
640
-
641
-        $tables = $this->schema->getTables();
642
-
643
-        foreach ($tables as $table) {
644
-            $tableName = $table->getName();
645
-            $tableToBeanMap[$tableName] = $beanNamespace . "\\" . self::getBeanNameFromTableName($tableName);
646
-        }
647
-        return $tableToBeanMap;
648
-    }
565
+	/**
566
+	 * Put the first letter of the string in lower case.
567
+	 * Very useful to transform a class name into a variable name.
568
+	 * 
569
+	 * @param $str string
570
+	 * @return string
571
+	 */
572
+	public static function toVariableName($str) {
573
+		return strtolower(substr($str, 0, 1)).substr($str, 1);
574
+	}
575
+
576
+	/**
577
+	 * Ensures the file passed in parameter can be written in its directory.
578
+	 * @param string $fileName
579
+	 */
580
+	private function ensureDirectoryExist($fileName) {
581
+		$dirName = dirname($fileName);
582
+		if (!file_exists($dirName)) {
583
+			$old = umask(0);
584
+			$result = mkdir($dirName, 0775, true);
585
+			umask($old);
586
+			if ($result == false) {
587
+				echo "Unable to create directory: ".$dirName.".";
588
+				exit;
589
+			}
590
+		}
591
+	}
592
+
593
+	/**
594
+	 * @param string $rootPath
595
+	 */
596
+	public function setRootPath($rootPath)
597
+	{
598
+		$this->rootPath = $rootPath;
599
+	}
600
+
601
+	/**
602
+	 * Transforms a DBAL type into a PHP type (for PHPDoc purpose)
603
+	 *
604
+	 * @param Type $type The DBAL type
605
+	 * @return string The PHP type
606
+	 */
607
+	public static function dbalTypeToPhpType(Type $type) {
608
+		$map = [
609
+			Type::TARRAY => 'array',
610
+			Type::SIMPLE_ARRAY => 'array',
611
+			Type::JSON_ARRAY => 'array',
612
+			Type::BIGINT => 'string',
613
+			Type::BOOLEAN => 'bool',
614
+			Type::DATETIME => '\DateTimeInterface',
615
+			Type::DATETIMETZ => '\DateTimeInterface',
616
+			Type::DATE => '\DateTimeInterface',
617
+			Type::TIME => '\DateTimeInterface',
618
+			Type::DECIMAL => 'float',
619
+			Type::INTEGER => 'int',
620
+			Type::OBJECT => 'string',
621
+			Type::SMALLINT => 'int',
622
+			Type::STRING => 'string',
623
+			Type::TEXT => 'string',
624
+			Type::BINARY => 'string',
625
+			Type::BLOB => 'string',
626
+			Type::FLOAT => 'float',
627
+			Type::GUID => 'string'
628
+		];
629
+
630
+		return isset($map[$type->getName()])?$map[$type->getName()]:$type->getName();
631
+	}
632
+
633
+	/**
634
+	 *
635
+	 * @param string $beanNamespace
636
+	 * @return \string[] Returns a map mapping table name to beans name
637
+	 */
638
+	public function buildTableToBeanMap($beanNamespace) {
639
+		$tableToBeanMap = [];
640
+
641
+		$tables = $this->schema->getTables();
642
+
643
+		foreach ($tables as $table) {
644
+			$tableName = $table->getName();
645
+			$tableToBeanMap[$tableName] = $beanNamespace . "\\" . self::getBeanNameFromTableName($tableName);
646
+		}
647
+		return $tableToBeanMap;
648
+	}
649 649
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
 }";
208 208
             $this->ensureDirectoryExist($possibleFileName);
209
-            file_put_contents($possibleFileName ,$str);
209
+            file_put_contents($possibleFileName, $str);
210 210
             @chmod($possibleFileName, 0664);
211 211
         }
212 212
     }
@@ -226,11 +226,11 @@  discard block
 block discarded – undo
226 226
         foreach ($table->getColumns() as $column) {
227 227
             $comments = $column->getComment();
228 228
             $matches = array();
229
-            if (preg_match('/@defaultSort(\((desc|asc)\))*/', $comments, $matches) != 0){
229
+            if (preg_match('/@defaultSort(\((desc|asc)\))*/', $comments, $matches) != 0) {
230 230
                 $defaultSort = $data['column_name'];
231
-                if (count($matches == 3)){
231
+                if (count($matches == 3)) {
232 232
                     $defaultSortDirection = $matches[2];
233
-                }else{
233
+                } else {
234 234
                     $defaultSortDirection = 'ASC';
235 235
                 }
236 236
             }
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
         $possibleBaseFileName = $this->rootPath.$possibleBaseFileNames[0];
417 417
 
418 418
         $this->ensureDirectoryExist($possibleBaseFileName);
419
-        file_put_contents($possibleBaseFileName ,$str);
419
+        file_put_contents($possibleBaseFileName, $str);
420 420
         @chmod($possibleBaseFileName, 0664);
421 421
 
422 422
         $possibleFileNames = $classNameMapper->getPossibleFileNames($daonamespace."\\".$className);
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 }
448 448
 ";
449 449
             $this->ensureDirectoryExist($possibleFileName);
450
-            file_put_contents($possibleFileName ,$str);
450
+            file_put_contents($possibleFileName, $str);
451 451
             @chmod($possibleFileName, 0664);
452 452
         }
453 453
     }
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
         $possibleFileName = $this->rootPath.$possibleFileNames[0];
524 524
 
525 525
         $this->ensureDirectoryExist($possibleFileName);
526
-        file_put_contents($possibleFileName ,$str);
526
+        file_put_contents($possibleFileName, $str);
527 527
     }
528 528
 
529 529
     /**
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
      * @return string
535 535
      */
536 536
     public static function toCamelCase($str) {
537
-        $str = strtoupper(substr($str,0,1)).substr($str,1);
537
+        $str = strtoupper(substr($str, 0, 1)).substr($str, 1);
538 538
         while (true) {
539 539
             if (strpos($str, "_") === false && strpos($str, " ") === false) {
540 540
                 break;
@@ -544,9 +544,9 @@  discard block
 block discarded – undo
544 544
             if ($pos === false) {
545 545
                 $pos = strpos($str, " ");
546 546
             }
547
-            $before = substr($str,0,$pos);
548
-            $after = substr($str,$pos+1);
549
-            $str = $before.strtoupper(substr($after,0,1)).substr($after,1);
547
+            $before = substr($str, 0, $pos);
548
+            $after = substr($str, $pos+1);
549
+            $str = $before.strtoupper(substr($after, 0, 1)).substr($after, 1);
550 550
         }
551 551
         return $str;
552 552
     }
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
             Type::GUID => 'string'
628 628
         ];
629 629
 
630
-        return isset($map[$type->getName()])?$map[$type->getName()]:$type->getName();
630
+        return isset($map[$type->getName()]) ? $map[$type->getName()] : $type->getName();
631 631
     }
632 632
 
633 633
     /**
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 
643 643
         foreach ($tables as $table) {
644 644
             $tableName = $table->getName();
645
-            $tableToBeanMap[$tableName] = $beanNamespace . "\\" . self::getBeanNameFromTableName($tableName);
645
+            $tableToBeanMap[$tableName] = $beanNamespace."\\".self::getBeanNameFromTableName($tableName);
646 646
         }
647 647
         return $tableToBeanMap;
648 648
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -230,7 +230,7 @@
 block discarded – undo
230 230
                 $defaultSort = $data['column_name'];
231 231
                 if (count($matches == 3)){
232 232
                     $defaultSortDirection = $matches[2];
233
-                }else{
233
+                } else{
234 234
                     $defaultSortDirection = 'ASC';
235 235
                 }
236 236
             }
Please login to merge, or discard this patch.
src/views/tdbmGenerate.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
 <div class="control-group">
46 46
 	<label class="control-label">Store dates / timestamps in UTC:</label>
47 47
 	<div class="controls">
48
-		<input type="checkbox" name="storeInUtc" value="1" <?php echo $this->storeInUtc?'checked="checked"':"" ?>></input>
48
+		<input type="checkbox" name="storeInUtc" value="1" <?php echo $this->storeInUtc ? 'checked="checked"' : "" ?>></input>
49 49
 		<span class="help-block">Select this option if you want timestamps to be stored in UTC.
50 50
 		If your application supports several time zones, you should select this option to store all dates in
51 51
 		the same time zone.</span>
Please login to merge, or discard this patch.
src/views/installStep2.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 <div class="control-group">
30 30
 	<label class="control-label">Store dates / timestamps in UTC:</label>
31 31
 	<div class="controls">
32
-		<input type="checkbox" name="storeInUtc" value="1" <?php echo $this->storeInUtc?'checked="checked"':"" ?>></input>
32
+		<input type="checkbox" name="storeInUtc" value="1" <?php echo $this->storeInUtc ? 'checked="checked"' : "" ?>></input>
33 33
 		<span class="help-block">Select this option if you want timestamps to be stored in UTC.
34 34
 		If your application supports several time zones, you should select this option to store all dates in
35 35
 		the same time zone.</span>
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/GreaterOrEqualFilter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@
 block discarded – undo
85 85
 	 * @param string $columnName
86 86
 	 * @param string $value
87 87
 	 */
88
-	public function __construct($tableName=null, $columnName=null, $value=null) {
88
+	public function __construct($tableName = null, $columnName = null, $value = null) {
89 89
 		$this->tableName = $tableName;
90 90
 		$this->columnName = $columnName;
91 91
 		$this->value = $value;
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/GreaterFilter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
 	 * @param string $columnName
85 85
 	 * @param string $value
86 86
 	 */
87
-	public function __construct($tableName=null, $columnName=null, $value=null) {
87
+	public function __construct($tableName = null, $columnName = null, $value = null) {
88 88
 		$this->tableName = $tableName;
89 89
 		$this->columnName = $columnName;
90 90
 		$this->value = $value;
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/InFilter.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * @param string $columnName
86 86
 	 * @param array<string> $values
87 87
 	 */
88
-	public function __construct($tableName=null, $columnName=null, $values=array()) {
88
+	public function __construct($tableName = null, $columnName = null, $values = array()) {
89 89
 		$this->tableName = $tableName;
90 90
 		$this->columnName = $columnName;
91 91
 		$this->values = $values;
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 			}
118 118
 		}
119 119
 
120
-		return $this->tableName.'.'.$this->columnName.' IN ('.implode(',',$values_sql).")";
120
+		return $this->tableName.'.'.$this->columnName.' IN ('.implode(',', $values_sql).")";
121 121
 	}
122 122
 
123 123
 	/**
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/OrderByColumn.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@
 block discarded – undo
86 86
 	 * @param string $columnName
87 87
 	 * @param string $order
88 88
 	 */
89
-	public function __construct($tableName=null, $columnName=null, $order=null) {
89
+	public function __construct($tableName = null, $columnName = null, $order = null) {
90 90
 		$this->tableName = $tableName;
91 91
 		$this->columnName = $columnName;
92 92
 		$this->order = $order;
Please login to merge, or discard this patch.
src/Mouf/Database/TDBM/Filters/EqualFilter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
 	 * @param string $columnName
85 85
 	 * @param string $value
86 86
 	 */
87
-	public function __construct($tableName=null, $columnName=null, $value=null) {
87
+	public function __construct($tableName = null, $columnName = null, $value = null) {
88 88
 		$this->tableName = $tableName;
89 89
 		$this->columnName = $columnName;
90 90
 		$this->value = $value;
Please login to merge, or discard this patch.