Completed
Pull Request — master (#38)
by Thomas
02:53
created

Entity::forceNamingScheme()   C

Complexity

Conditions 10
Paths 9

Size

Total Lines 49
Code Lines 35

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 33
CRAP Score 10

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 49
ccs 33
cts 33
cp 1
rs 5.5471
cc 10
eloc 35
nc 9
nop 2
crap 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B Entity::__set() 0 21 6

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace ORM;
4
5
use ORM\Dbal\Column;
6
use ORM\Exceptions\IncompletePrimaryKey;
7
use ORM\Exceptions\InvalidConfiguration;
8
use ORM\Exceptions\InvalidRelation;
9
use ORM\Exceptions\InvalidName;
10
use ORM\Exceptions\NoEntityManager;
11
use ORM\Exceptions\UndefinedRelation;
12
use ORM\Dbal\Error;
13
use ORM\Dbal\Table;
14
15
/**
16
 * Definition of an entity
17
 *
18
 * The instance of an entity represents a row of the table and the statics variables and methods describe the database
19
 * table.
20
 *
21
 * This is the main part where your configuration efforts go. The following properties and methods are well documented
22
 * in the manual under [https://tflori.github.io/orm/entityDefinition.html](Entity Definition).
23
 *
24
 * @package ORM
25
 * @link https://tflori.github.io/orm/entityDefinition.html Entity Definition
26
 * @author Thomas Flori <[email protected]>
27
 */
28
abstract class Entity implements \Serializable
29
{
30
    const OPT_RELATION_CLASS       = 'class';
31
    const OPT_RELATION_CARDINALITY = 'cardinality';
32
    const OPT_RELATION_REFERENCE   = 'reference';
33
    const OPT_RELATION_OPPONENT    = 'opponent';
34
    const OPT_RELATION_TABLE       = 'table';
35
36
    /** The template to use to calculate the table name.
37
     * @var string */
38
    protected static $tableNameTemplate;
39
40
    /** The naming scheme to use for table names.
41
     * @var string */
42
    protected static $namingSchemeTable;
43
44
    /** The naming scheme to use for column names.
45
     * @var string */
46
    protected static $namingSchemeColumn;
47
48
    /** The naming scheme to use for method names.
49
     * @var string */
50
    protected static $namingSchemeMethods;
51
52
    /** Whether or not the naming got used
53
     * @var bool */
54
    protected static $namingUsed = false;
55
56
    /** Fixed table name (ignore other settings)
57
     * @var string */
58
    protected static $tableName;
59
60
    /** The variable(s) used for primary key.
61
     * @var string[]|string */
62
    protected static $primaryKey = ['id'];
63
64
    /** Fixed column names (ignore other settings)
65
     * @var string[] */
66
    protected static $columnAliases = [];
67
68
    /** A prefix for column names.
69
     * @var string */
70
    protected static $columnPrefix;
71
72
    /** Whether or not the primary key is auto incremented.
73
     * @var bool */
74
    protected static $autoIncrement = true;
75
76
    /** Relation definitions
77
     * @var array */
78
    protected static $relations = [];
79
80
    /** The current data of a row.
81
     * @var mixed[] */
82
    protected $data = [];
83
84
    /** The original data of the row.
85
     * @var mixed[] */
86
    protected $originalData = [];
87
88
    /** The entity manager from which this entity got created
89
     * @var EntityManager*/
90
    protected $entityManager;
91
92
    /** Related objects for getRelated
93
     * @var array */
94
    protected $relatedObjects = [];
95
96
    /** Calculated table names.
97
     * @internal
98
     * @var string[] */
99
    protected static $calculatedTableNames = [];
100
101
    /** Calculated column names.
102
     * @internal
103
     * @var string[][] */
104
    protected static $calculatedColumnNames = [];
105
106
    /** The reflections of the classes.
107
     * @internal
108
     * @var \ReflectionClass[] */
109
    protected static $reflections = [];
110
111
    /** Fetched table descriptions
112
     * @var Table[] */
113
    protected static $tableDescriptions = [];
114
115
    /**
116
     * Get the table name
117
     *
118
     * The table name is constructed by $tableNameTemplate and $namingSchemeTable. It can be overwritten by
119
     * $tableName.
120
     *
121
     * @return string
122
     * @throws InvalidName|InvalidConfiguration
123
     */
124 136
    public static function getTableName()
125
    {
126 136
        if (static::$tableName) {
127 11
            return static::$tableName;
128
        }
129
130 125
        if (!isset(self::$calculatedTableNames[static::class])) {
131 125
            static::$namingUsed = true;
132 125
            $reflection = self::getReflection();
133
134 125
            $em = EntityManager::getInstance(static::class);
135 125
            $tnt = static::$tableNameTemplate;
136 125
            $nst = static::$namingSchemeTable;
137 125
            $tableName = $em->getNamer()->getTableName($reflection, $tnt, $nst);
138
139 123
            if (empty($tableName)) {
140 2
                throw new InvalidName('Table name can not be empty');
141
            }
142
143 121
            self::$calculatedTableNames[static::class] = $tableName;
144
        }
145
146 121
        return self::$calculatedTableNames[static::class];
147
    }
148
149
    /**
150
     * Get the column name of $field
151
     *
152
     * The column names can not be specified by template. Instead they are constructed by $columnPrefix and enforced
153
     * to $namingSchemeColumn.
154
     *
155
     * **ATTENTION**: If your overwrite this method remember that getColumnName(getColumnName($name)) have to be exactly
156
     * the same as getColumnName($name).
157
     *
158
     * @param string $field
159
     * @return string
160
     * @throws InvalidConfiguration
161
     */
162 138
    public static function getColumnName($field)
163
    {
164 138
        if (isset(static::$columnAliases[$field])) {
165 6
            return static::$columnAliases[$field];
166
        }
167
168 136
        if (!isset(self::$calculatedColumnNames[static::class][$field])) {
169 136
            static::$namingUsed = true;
170 136
            $colName = $field;
171
172 136
            $em = EntityManager::getInstance(static::class);
173 136
            $namer = $em->getNamer();
174
175 136
            if (static::$columnPrefix && strpos($colName, static::$columnPrefix) !== 0) {
176 22
                $colName = static::$columnPrefix . $colName;
177
            }
178
179 136
            self::$calculatedColumnNames[static::class][$field] =
180 136
                $namer->getColumnName($colName, static::$namingSchemeColumn);
181
        }
182
183 136
        return self::$calculatedColumnNames[static::class][$field];
184
    }
185
186
    /**
187
     * Get the definition for $relation
188
     *
189
     * It normalize the short definition form and create a Relation object from it.
190
     *
191
     * @param string $relation
192
     * @return Relation
193
     * @throws InvalidConfiguration
194
     * @throws UndefinedRelation
195
     */
196 84
    public static function getRelation($relation)
197
    {
198 84
        if (!isset(static::$relations[$relation])) {
199 3
            throw new UndefinedRelation('Relation ' . $relation . ' is not defined');
200
        }
201
202 83
        $relDef = &static::$relations[$relation];
203
204 83
        if (!$relDef instanceof Relation) {
205 15
            $relDef = Relation::createRelation($relation, $relDef);
206
        }
207
208 82
        return $relDef;
209
    }
210
211
    /**
212
     * Initialize the validator for this Entity.
213
     *
214
     * @param EntityManager $entityManager
215
     */
216 2
    public static function initValidator(EntityManager $entityManager)
217
    {
218 2
        if (isset(self::$tableDescriptions[static::class])) {
219 1
            return;
220
        }
221
222 1
        self::$tableDescriptions[static::class] = static::describe($entityManager);
223 1
    }
224
225
    /**
226
     * Check if the validator is initialized.
227
     *
228
     * @return bool
229
     */
230 2
    public static function validatorIsInitialized()
231
    {
232 2
        return isset(self::$tableDescriptions[static::class]);
233
    }
234
235
    /**
236
     * Validate $value for $field.
237
     *
238
     * @param string $field
239
     * @param mixed $value
240
     * @return bool|Error
241
     * @throws Exception
242
     */
243 5
    public static function validate($field, $value)
244
    {
245 5
        if (!isset(self::$tableDescriptions[static::class])) {
246 1
            throw new Exception('Validator not initialized yet');
247
        }
248
249 4
        $table = self::$tableDescriptions[static::class];
250
251 4
        return $table->validate(static::getColumnName($field), $value);
252
    }
253
254
    /**
255
     * Validate $fields.
256
     *
257
     * $fields has to be an array of $field => $value
258
     *
259
     * @param array $fields
260
     * @return array
261
     */
262 1
    public static function validateArray(array $fields)
263
    {
264 1
        $result = $fields;
265 1
        foreach ($result as $field => &$value) {
266 1
            $value = static::validate($field, $value);
267
        }
268 1
        return $result;
269
    }
270
271
    /**
272
     * Get the primary key vars
273
     *
274
     * The primary key can consist of multiple columns. You should configure the vars that are translated to these
275
     * columns.
276
     *
277
     * @return array
278
     */
279 56
    public static function getPrimaryKeyVars()
280
    {
281 56
        return !is_array(static::$primaryKey) ? [static::$primaryKey] : static::$primaryKey;
282
    }
283
284
    /**
285
     * Check if the table has a auto increment column.
286
     *
287
     * @return bool
288
     */
289 14
    public static function isAutoIncremented()
290
    {
291 14
        return count(static::getPrimaryKeyVars()) > 1 ? false : static::$autoIncrement;
292
    }
293
294
    /**
295
     * Get an array of Columns for this table.
296
     *
297
     * @param EntityManager $entityManager
298
     * @return Column[]
299
     * @codeCoverageIgnore This is just a proxy
300
     */
301
    public static function describe(EntityManager $entityManager)
302
    {
303
        return $entityManager->describe(static::getTableName());
304
    }
305
306
    /**
307
     * Get reflection of the entity
308
     *
309
     * @return \ReflectionClass
310
     */
311 125
    protected static function getReflection()
312
    {
313 125
        if (!isset(self::$reflections[static::class])) {
314 125
            self::$reflections[static::class] = new \ReflectionClass(static::class);
315
        }
316 125
        return self::$reflections[static::class];
317
    }
318
319
    /**
320
     * Constructor
321
     *
322
     * It calls ::onInit() after initializing $data and $originalData.
323
     *
324
     * @param mixed[]       $data          The current data
325
     * @param EntityManager $entityManager The EntityManager that created this entity
326
     * @param bool          $fromDatabase  Whether or not the data comes from database
327
     */
328 109
    final public function __construct(array $data = [], EntityManager $entityManager = null, $fromDatabase = false)
329
    {
330 109
        if ($fromDatabase) {
331 14
            $this->originalData = $data;
332
        }
333 109
        $this->data = array_merge($this->data, $data);
334 109
        $this->entityManager = $entityManager;
335 109
        $this->onInit(!$fromDatabase);
336 109
    }
337
338
    /**
339
     * @param EntityManager $entityManager
340
     * @return self
341
     */
342 1
    public function setEntityManager(EntityManager $entityManager)
343
    {
344 1
        $this->entityManager = $entityManager;
345 1
        return $this;
346
    }
347
348
    /**
349
     * Set $var to $value
350
     *
351
     * Tries to call custom setter before it stores the data directly. If there is a setter the setter needs to store
352
     * data that should be updated in the database to $data. Do not store data in $originalData as it will not be
353
     * written and give wrong results for dirty checking.
354
     *
355
     * The onChange event is called after something got changed.
356
     *
357
     * @param string $var   The variable to change
358
     * @param mixed  $value The value to store
359
     * @throws IncompletePrimaryKey
360
     * @throws InvalidConfiguration
361
     * @link https://tflori.github.io/orm/entities.html Working with entities
362
     */
363 18
    public function __set($var, $value)
364
    {
365 18
        $col = $this->getColumnName($var);
366
367 18
        $em = $this->entityManager ?: EntityManager::getInstance(static::class);
368 18
        $setter = $em->getNamer()->getMethodName('set' . ucfirst($var), self::$namingSchemeMethods);
369 18
        if (method_exists($this, $setter) && is_callable([$this, $setter])) {
370 3
            $oldValue = $this->__get($var);
371 3
            $md5OldData = md5(serialize($this->data));
372 3
            $this->$setter($value);
373 3
            $changed = $md5OldData !== md5(serialize($this->data));
374
        } else {
375 15
            $oldValue = $this->__get($var);
376 15
            $changed = (isset($this->data[$col]) ? $this->data[$col] : null) !== $value;
377 15
            $this->data[$col] = $value;
378
        }
379
380 18
        if ($changed) {
381 15
            $this->onChange($var, $oldValue, $this->__get($var));
382
        }
383 18
    }
384
385
    /**
386
     * Get the value from $var
387
     *
388
     * If there is a custom getter this method get called instead.
389
     *
390
     * @param string $var The variable to get
391
     * @return mixed|null
392
     * @throws IncompletePrimaryKey
393
     * @throws InvalidConfiguration
394
     * @link https://tflori.github.io/orm/entities.html Working with entities
395
     */
396 86
    public function __get($var)
397
    {
398 86
        $em = $this->entityManager ?: EntityManager::getInstance(static::class);
399 86
        $getter = $em->getNamer()->getMethodName('get' . ucfirst($var), self::$namingSchemeMethods);
400 86
        if (method_exists($this, $getter) && is_callable([$this, $getter])) {
401 4
            return $this->$getter();
402
        } else {
403 82
            $col = static::getColumnName($var);
404 82
            $result = isset($this->data[$col]) ? $this->data[$col] : null;
405
406 82
            if (!$result && isset(static::$relations[$var]) && isset($this->entityManager)) {
407 1
                return $this->getRelated($var);
408
            }
409
410 81
            return $result;
411
        }
412
    }
413
414
    /**
415
     * Get related objects
416
     *
417
     * The difference between getRelated and fetch is that getRelated stores the fetched entities. To refresh set
418
     * $refresh to true.
419
     *
420
     * @param string $relation
421
     * @param bool   $refresh
422
     * @return mixed
423
     * @throws Exceptions\NoConnection
424
     * @throws Exceptions\NoEntity
425
     * @throws IncompletePrimaryKey
426
     * @throws InvalidConfiguration
427
     * @throws NoEntityManager
428
     * @throws UndefinedRelation
429
     */
430 11
    public function getRelated($relation, $refresh = false)
431
    {
432 11
        if ($refresh || !isset($this->relatedObjects[$relation])) {
433 9
            $this->relatedObjects[$relation] = $this->fetch($relation, null, true);
434
        }
435
436 11
        return $this->relatedObjects[$relation];
437
    }
438
439
    /**
440
     * Set $relation to $entity
441
     *
442
     * This method is only for the owner of a relation.
443
     *
444
     * @param string $relation
445
     * @param Entity $entity
446
     * @throws IncompletePrimaryKey
447
     * @throws InvalidRelation
448
     */
449 7
    public function setRelated($relation, Entity $entity = null)
450
    {
451 7
        $this::getRelation($relation)->setRelated($this, $entity);
452
453 4
        $this->relatedObjects[$relation] = $entity;
454 4
    }
455
456
    /**
457
     * Add relations for $relation to $entities
458
     *
459
     * This method is only for many-to-many relations.
460
     *
461
     * This method does not take care about already existing relations and will fail hard.
462
     *
463
     * @param string        $relation
464
     * @param Entity[]      $entities
465
     * @param EntityManager $entityManager
466
     * @throws NoEntityManager
467
     */
468 9
    public function addRelated($relation, array $entities, EntityManager $entityManager = null)
469
    {
470 9
        $entityManager = $entityManager ?: $this->entityManager;
471
472 9
        if (!$entityManager) {
473 1
            throw new NoEntityManager('No entity manager given');
474
        }
475
476 8
        $this::getRelation($relation)->addRelated($this, $entities, $entityManager);
477 4
    }
478
479
    /**
480
     * Delete relations for $relation to $entities
481
     *
482
     * This method is only for many-to-many relations.
483
     *
484
     * @param string        $relation
485
     * @param Entity[]      $entities
486
     * @param EntityManager $entityManager
487
     * @throws NoEntityManager
488
     */
489 9
    public function deleteRelated($relation, $entities, EntityManager $entityManager = null)
490
    {
491 9
        $entityManager = $entityManager ?: $this->entityManager;
492
493 9
        if (!$entityManager) {
494 1
            throw new NoEntityManager('No entity manager given');
495
        }
496
497 8
        $this::getRelation($relation)->deleteRelated($this, $entities, $entityManager);
498 4
    }
499
500
    /**
501
     * Checks if entity or $var got changed
502
     *
503
     * @param string $var Check only this variable or all variables
504
     * @return bool
505
     * @throws InvalidConfiguration
506
     */
507 18
    public function isDirty($var = null)
508
    {
509 18
        if (!empty($var)) {
510 4
            $col = static::getColumnName($var);
511 4
            return (isset($this->data[$col]) ? $this->data[$col] : null) !==
512 4
                   (isset($this->originalData[$col]) ? $this->originalData[$col] : null);
513
        }
514
515 15
        ksort($this->data);
516 15
        ksort($this->originalData);
517
518 15
        return serialize($this->data) !== serialize($this->originalData);
519
    }
520
521
    /**
522
     * Resets the entity or $var to original data
523
     *
524
     * @param string $var Reset only this variable or all variables
525
     * @throws InvalidConfiguration
526
     */
527 8
    public function reset($var = null)
528
    {
529 8
        if (!empty($var)) {
530 3
            $col = static::getColumnName($var);
531 3
            if (isset($this->originalData[$col])) {
532 2
                $this->data[$col] = $this->originalData[$col];
533
            } else {
534 1
                unset($this->data[$col]);
535
            }
536 3
            return;
537
        }
538
539 5
        $this->data = $this->originalData;
540 5
    }
541
542
    /**
543
     * Save the entity to $entityManager
544
     *
545
     * @param EntityManager $entityManager
546
     * @return Entity
547
     * @throws Exceptions\NoConnection
548
     * @throws Exceptions\NoEntity
549
     * @throws Exceptions\NotScalar
550
     * @throws Exceptions\UnsupportedDriver
551
     * @throws IncompletePrimaryKey
552
     * @throws InvalidConfiguration
553
     * @throws InvalidName
554
     * @throws NoEntityManager
555
     */
556 13
    public function save(EntityManager $entityManager = null)
557
    {
558 13
        $entityManager = $entityManager ?: $this->entityManager;
559
560 13
        if (!$entityManager) {
561 1
            throw new NoEntityManager('No entity manager given');
562
        }
563
564 12
        $inserted = false;
565 12
        $updated = false;
566
567
        try {
568
            // this may throw if the primary key is auto incremented but we using this to omit duplicated code
569 12
            if (!$entityManager->sync($this)) {
570 2
                $entityManager->insert($this, false);
571 2
                $inserted = true;
572 5
            } elseif ($this->isDirty()) {
573 4
                $this->preUpdate();
574 4
                $entityManager->update($this);
575 7
                $updated = true;
576
            }
577 5
        } catch (IncompletePrimaryKey $e) {
578 5
            if (static::isAutoIncremented()) {
579 4
                $this->prePersist();
580 4
                $id = $entityManager->insert($this);
581 4
                $this->data[static::getColumnName(static::getPrimaryKeyVars()[0])] = $id;
582 4
                $inserted = true;
583
            } else {
584 1
                throw $e;
585
            }
586
        }
587
588 11
        if ($inserted || $updated) {
589 10
            $inserted && $this->postPersist();
590 10
            $updated && $this->postUpdate();
591 10
            $entityManager->sync($this, true);
592
        }
593
594 11
        return $this;
595
    }
596
597
    /**
598
     * Fetches related objects
599
     *
600
     * For relations with cardinality many it returns an EntityFetcher. Otherwise it returns the entity.
601
     *
602
     * It will throw an error for non owner when the key is incomplete.
603
     *
604
     * @param string        $relation      The relation to fetch
605
     * @param EntityManager $entityManager The EntityManager to use
606
     * @param bool          $getAll
607
     * @return Entity|Entity[]|EntityFetcher
608
     * @throws NoEntityManager
609
     */
610 19
    public function fetch($relation, EntityManager $entityManager = null, $getAll = false)
611
    {
612 19
        $entityManager = $entityManager ?: $this->entityManager;
613
614 19
        if (!$entityManager) {
615 1
            throw new NoEntityManager('No entity manager given');
616
        }
617
618 18
        $relation = $this::getRelation($relation);
619
620 18
        if ($getAll) {
621 4
            return $relation->fetchAll($this, $entityManager);
622
        } else {
623 14
            return $relation->fetch($this, $entityManager);
624
        }
625
    }
626
627
    /**
628
     * Get the primary key
629
     *
630
     * @return array
631
     * @throws IncompletePrimaryKey
632
     */
633 38
    public function getPrimaryKey()
634
    {
635 38
        $primaryKey = [];
636 38
        foreach (static::getPrimaryKeyVars() as $var) {
637 38
            $value = $this->$var;
638 38
            if ($value === null) {
639 4
                throw new IncompletePrimaryKey('Incomplete primary key - missing ' . $var);
640
            }
641 36
            $primaryKey[$var] = $value;
642
        }
643 34
        return $primaryKey;
644
    }
645
646
    /**
647
     * Get current data
648
     *
649
     * @return array
650
     * @internal
651
     */
652 20
    public function getData()
653
    {
654 20
        return $this->data;
655
    }
656
657
    /**
658
     * Set new original data
659
     *
660
     * @param array $data
661
     * @internal
662
     */
663 18
    public function setOriginalData(array $data)
664
    {
665 18
        $this->originalData = $data;
666 18
    }
667
668
    /**
669
     * Empty event handler
670
     *
671
     * Get called when something is changed with magic setter.
672
     *
673
     * @param string $var The variable that got changed.merge(node.inheritedProperties)
674
     * @param mixed  $oldValue The old value of the variable
675
     * @param mixed  $value The new value of the variable
676
     */
677 6
    public function onChange($var, $oldValue, $value)
678
    {
679 6
    }
680
681
    /**
682
     * Empty event handler
683
     *
684
     * Get called when the entity get initialized.
685
     *
686
     * @param bool $new Whether or not the entity is new or from database
687
     */
688 108
    public function onInit($new)
689
    {
690 108
    }
691
692
    /**
693
     * Empty event handler
694
     *
695
     * Get called before the entity get inserted in database.
696
     */
697 3
    public function prePersist()
698
    {
699 3
    }
700
701
    /**
702
     * Empty event handler
703
     *
704
     * Get called after the entity got inserted in database.
705
     */
706 5
    public function postPersist()
707
    {
708 5
    }
709
710
    /**
711
     * Empty event handler
712
     *
713
     * Get called before the entity get updated in database.
714
     */
715 3
    public function preUpdate()
716
    {
717 3
    }
718
719
    /**
720
     * Empty event handler
721
     *
722
     * Get called after the entity got updated in database.
723
     */
724 3
    public function postUpdate()
725
    {
726 3
    }
727
728
    /**
729
     * String representation of data
730
     *
731
     * @link http://php.net/manual/en/serializable.serialize.php
732
     * @return string
733
     */
734 2
    public function serialize()
735
    {
736 2
        return serialize([$this->data, $this->relatedObjects]);
737
    }
738
739
    /**
740
     * Constructs the object
741
     *
742
     * @link http://php.net/manual/en/serializable.unserialize.php
743
     * @param string $serialized The string representation of data
744
     */
745 3
    public function unserialize($serialized)
746
    {
747 3
        list($this->data, $this->relatedObjects) = unserialize($serialized);
748 3
        $this->onInit(false);
749 3
    }
750
751
752
    // DEPRECATED stuff
753
754
    /**
755
     * @return string
756
     * @deprecated use getOption from EntityManager
757
     * @codeCoverageIgnore deprecated
758
     */
759
    public static function getTableNameTemplate()
760
    {
761
        return static::$tableNameTemplate;
762
    }
763
764
    /**
765
     * @param string $tableNameTemplate
766
     * @deprecated use setOption from EntityManager
767
     * @codeCoverageIgnore deprecated
768
     */
769
    public static function setTableNameTemplate($tableNameTemplate)
770
    {
771
        static::$tableNameTemplate = $tableNameTemplate;
772
    }
773
774
    /**
775
     * @return string
776
     * @deprecated use getOption from EntityManager
777
     * @codeCoverageIgnore deprecated
778
     */
779
    public static function getNamingSchemeTable()
780
    {
781
        return static::$namingSchemeTable;
782
    }
783
784
    /**
785
     * @param string $namingSchemeTable
786
     * @deprecated use setOption from EntityManager
787
     * @codeCoverageIgnore deprecated
788
     */
789
    public static function setNamingSchemeTable($namingSchemeTable)
790
    {
791
        static::$namingSchemeTable = $namingSchemeTable;
792
    }
793
794
    /**
795
     * @return string
796
     * @deprecated use getOption from EntityManager
797
     * @codeCoverageIgnore deprecated
798
     */
799
    public static function getNamingSchemeColumn()
800
    {
801
        return static::$namingSchemeColumn;
802
    }
803
804
    /**
805
     * @param string $namingSchemeColumn
806
     * @deprecated use setOption from EntityManager
807
     * @codeCoverageIgnore deprecated
808
     */
809
    public static function setNamingSchemeColumn($namingSchemeColumn)
810
    {
811
        static::$namingSchemeColumn = $namingSchemeColumn;
812
    }
813
814
    /**
815
     * @return string
816
     * @deprecated use getOption from EntityManager
817
     * @codeCoverageIgnore deprecated
818
     */
819
    public static function getNamingSchemeMethods()
820
    {
821
        return static::$namingSchemeMethods;
822
    }
823
824
    /**
825
     * @param string $namingSchemeMethods
826
     * @deprecated use setOption from EntityManager
827
     * @codeCoverageIgnore deprecated
828
     */
829
    public static function setNamingSchemeMethods($namingSchemeMethods)
830
    {
831
        static::$namingSchemeMethods = $namingSchemeMethods;
832
    }
833
}
834