Passed
Pull Request — master (#41)
by Thomas
02:55
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  
A Entity::fill() 0 12 4

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\Exception\IncompletePrimaryKey;
7
use ORM\Exception\InvalidConfiguration;
8
use ORM\Exception\InvalidRelation;
9
use ORM\Exception\InvalidName;
10
use ORM\Exception\NoEntityManager;
11
use ORM\Exception\UndefinedRelation;
12
use ORM\Dbal\Error;
13
use ORM\Dbal\Table;
14
use ORM\EntityManager as EM;
15
use ORM\Exception\UnknownColumn;
16
17
/**
18
 * Definition of an entity
19
 *
20
 * The instance of an entity represents a row of the table and the statics variables and methods describe the database
21
 * table.
22
 *
23
 * This is the main part where your configuration efforts go. The following properties and methods are well documented
24
 * in the manual under [https://tflori.github.io/orm/entityDefinition.html](Entity Definition).
25
 *
26
 * @package ORM
27
 * @link https://tflori.github.io/orm/entityDefinition.html Entity Definition
28
 * @author Thomas Flori <[email protected]>
29
 */
30
abstract class Entity implements \Serializable
31
{
32
    /** @deprecated Use Relation::OPT_CLASS instead */
33
    const OPT_RELATION_CLASS       = 'class';
34
    /** @deprecated Use Relation::OPT_CARDINALITY instead */
35
    const OPT_RELATION_CARDINALITY = 'cardinality';
36
    /** @deprecated Use Relation::OPT_REFERENCE instead */
37
    const OPT_RELATION_REFERENCE   = 'reference';
38
    /** @deprecated Use Relation::OPT_OPPONENT instead */
39
    const OPT_RELATION_OPPONENT    = 'opponent';
40
    /** @deprecated Use Relation::OPT_TABLE instead */
41
    const OPT_RELATION_TABLE       = 'table';
42
43
    /** The template to use to calculate the table name.
44
     * @var string */
45
    protected static $tableNameTemplate;
46
47
    /** The naming scheme to use for table names.
48
     * @var string */
49
    protected static $namingSchemeTable;
50
51
    /** The naming scheme to use for column names.
52
     * @var string */
53
    protected static $namingSchemeColumn;
54
55
    /** The naming scheme to use for method names.
56
     * @var string */
57
    protected static $namingSchemeMethods;
58
59
    /** Fixed table name (ignore other settings)
60
     * @var string */
61
    protected static $tableName;
62
63
    /** The variable(s) used for primary key.
64
     * @var string[]|string */
65
    protected static $primaryKey = ['id'];
66
67
    /** Fixed column names (ignore other settings)
68
     * @var string[] */
69
    protected static $columnAliases = [];
70
71
    /** A prefix for column names.
72
     * @var string */
73
    protected static $columnPrefix;
74
75
    /** Whether or not the primary key is auto incremented.
76
     * @var bool */
77
    protected static $autoIncrement = true;
78
79
    /** Whether or not the validator for this class is enabled.
80
     * @var bool */
81
    protected static $enableValidator = false;
82
83
    /** Whether or not the validator for a class got enabled during runtime.
84
     * @var bool[] */
85
    protected static $enabledValidators = [];
86
87
    /** Relation definitions
88
     * @var array */
89
    protected static $relations = [];
90
91
    /** The reflections of the classes.
92
     * @internal
93
     * @var \ReflectionClass[] */
94
    protected static $reflections = [];
95
96
    /** The current data of a row.
97
     * @var mixed[] */
98
    protected $data = [];
99
100
    /** The original data of the row.
101
     * @var mixed[] */
102
    protected $originalData = [];
103
104
    /** The entity manager from which this entity got created
105
     * @var EM */
106
    protected $entityManager;
107
108
    /** Related objects for getRelated
109
     * @var array */
110
    protected $relatedObjects = [];
111
112
    /**
113
     * Constructor
114
     *
115
     * It calls ::onInit() after initializing $data and $originalData.
116
     *
117
     * @param mixed[] $data The current data
118
     * @param EM $entityManager The EntityManager that created this entity
119
     * @param bool $fromDatabase Whether or not the data comes from database
120
     */
121 113
    final public function __construct(array $data = [], EM $entityManager = null, $fromDatabase = false)
122
    {
123 113
        if ($fromDatabase) {
124 14
            $this->originalData = $data;
125
        }
126 113
        $this->data = array_merge($this->data, $data);
127 113
        $this->entityManager = $entityManager ?: EM::getInstance(static::class);
128 113
        $this->onInit(!$fromDatabase);
129 113
    }
130
131
    /**
132
     * Get a description for this table.
133
     *
134
     * @return Table|Column[]
135
     * @codeCoverageIgnore This is just a proxy
136
     */
137
    public static function describe()
138
    {
139
        return EM::getInstance(static::class)->describe(static::getTableName());
140
    }
141
142
    /**
143
     * Get the column name of $attribute
144
     *
145
     * The column names can not be specified by template. Instead they are constructed by $columnPrefix and enforced
146
     * to $namingSchemeColumn.
147
     *
148
     * **ATTENTION**: If your overwrite this method remember that getColumnName(getColumnName($name)) have to be exactly
149
     * the same as getColumnName($name).
150
     *
151
     * @param string $attribute
152
     * @return string
153
     * @throws InvalidConfiguration
154
     */
155 145
    public static function getColumnName($attribute)
156
    {
157 145
        if (isset(static::$columnAliases[$attribute])) {
158 6
            return static::$columnAliases[$attribute];
159
        }
160
161 143
        return EM::getInstance(static::class)->getNamer()
162 143
            ->getColumnName(static::class, $attribute, static::$columnPrefix, static::$namingSchemeColumn);
163
    }
164
165
    /**
166
     * Get the primary key vars
167
     *
168
     * The primary key can consist of multiple columns. You should configure the vars that are translated to these
169
     * columns.
170
     *
171
     * @return array
172
     */
173 56
    public static function getPrimaryKeyVars()
174
    {
175 56
        return !is_array(static::$primaryKey) ? [static::$primaryKey] : static::$primaryKey;
176
    }
177
178
    /**
179
     * Get the definition for $relation
180
     *
181
     * It normalize the short definition form and create a Relation object from it.
182
     *
183
     * @param string $relation
184
     * @return Relation
185
     * @throws InvalidConfiguration
186
     * @throws UndefinedRelation
187
     */
188 85
    public static function getRelation($relation)
189
    {
190 85
        if (!isset(static::$relations[$relation])) {
191 3
            throw new UndefinedRelation('Relation ' . $relation . ' is not defined');
192
        }
193
194 84
        $relDef = &static::$relations[$relation];
195
196 84
        if (!$relDef instanceof Relation) {
197 15
            $relDef = Relation::createRelation($relation, $relDef);
198
        }
199
200 83
        return $relDef;
201
    }
202
203
    /**
204
     * Get the table name
205
     *
206
     * The table name is constructed by $tableNameTemplate and $namingSchemeTable. It can be overwritten by
207
     * $tableName.
208
     *
209
     * @return string
210
     * @throws InvalidName|InvalidConfiguration
211
     */
212 146
    public static function getTableName()
213
    {
214 146
        if (static::$tableName) {
215 11
            return static::$tableName;
216
        }
217
218 135
        return EM::getInstance(static::class)->getNamer()
219 135
            ->getTableName(static::class, static::$tableNameTemplate, static::$namingSchemeTable);
220
    }
221
222
    /**
223
     * Check if the table has a auto increment column
224
     *
225
     * @return bool
226
     */
227 14
    public static function isAutoIncremented()
228
    {
229 14
        return count(static::getPrimaryKeyVars()) > 1 ? false : static::$autoIncrement;
230
    }
231
232
    /**
233
     * Check if the validator is enabled
234
     *
235
     * @return bool
236
     */
237 26
    public static function isValidatorEnabled()
238
    {
239 26
        return isset(self::$enabledValidators[static::class]) ?
240 26
            self::$enabledValidators[static::class] : static::$enableValidator;
241
    }
242
243
    /**
244
     * Enable validator
245
     *
246
     * @param bool $enable
247
     */
248 7
    public static function enableValidator($enable = true)
249
    {
250 7
        self::$enabledValidators[static::class] = $enable;
251 7
    }
252
253
    /**
254
     * Disable validator
255
     *
256
     * @param bool $disable
257
     */
258 1
    public static function disableValidator($disable = true)
259
    {
260 1
        self::$enabledValidators[static::class] = !$disable;
261 1
    }
262
263
    /**
264
     * Validate $value for $attribute
265
     *
266
     * @param string $attribute
267
     * @param mixed $value
268
     * @return bool|Error
269
     * @throws Exception
270
     */
271 9
    public static function validate($attribute, $value)
272
    {
273 9
        return static::describe()->validate(static::getColumnName($attribute), $value);
274
    }
275
276
    /**
277
     * Validate $data
278
     *
279
     * $data has to be an array of $attribute => $value
280
     *
281
     * @param array $data
282
     * @return array
283
     */
284 1
    public static function validateArray(array $data)
285
    {
286 1
        $result = $data;
287 1
        foreach ($result as $attribute => &$value) {
288 1
            $value = static::validate($attribute, $value);
289
        }
290 1
        return $result;
291
    }
292
293
    /**
294
     * @param EM $entityManager
295
     * @return self
296
     */
297 2
    public function setEntityManager(EM $entityManager)
298
    {
299 2
        $this->entityManager = $entityManager;
300 2
        return $this;
301
    }
302
303
    /**
304
     * Get the value from $attribute
305
     *
306
     * If there is a custom getter this method get called instead.
307
     *
308
     * @param string $attribute The variable to get
309
     * @return mixed|null
310
     * @throws IncompletePrimaryKey
311
     * @throws InvalidConfiguration
312
     * @link https://tflori.github.io/orm/entities.html Working with entities
313
     */
314 90
    public function __get($attribute)
315
    {
316 90
        $em = EM::getInstance(static::class);
317 90
        $getter = $em->getNamer()->getMethodName('get' . ucfirst($attribute), self::$namingSchemeMethods);
318
319 90
        if (method_exists($this, $getter) && is_callable([$this, $getter])) {
320 4
            return $this->$getter();
321
        } else {
322 86
            $col = static::getColumnName($attribute);
323 86
            $result = isset($this->data[$col]) ? $this->data[$col] : null;
324
325 86
            if (!$result && isset(static::$relations[$attribute]) && isset($this->entityManager)) {
326 1
                return $this->getRelated($attribute);
327
            }
328
329 85
            return $result;
330
        }
331
    }
332
333
    /**
334
     * Set $attribute to $value
335
     *
336
     * Tries to call custom setter before it stores the data directly. If there is a setter the setter needs to store
337
     * data that should be updated in the database to $data. Do not store data in $originalData as it will not be
338
     * written and give wrong results for dirty checking.
339
     *
340
     * The onChange event is called after something got changed.
341
     *
342
     * @param string $attribute The variable to change
343
     * @param mixed  $value     The value to store
344
     * @throws Error
345
     * @link https://tflori.github.io/orm/entities.html Working with entities
346
     */
347 25
    public function __set($attribute, $value)
348
    {
349 25
        $col = $this->getColumnName($attribute);
350
351 25
        $em = EM::getInstance(static::class);
352 25
        $setter = $em->getNamer()->getMethodName('set' . ucfirst($attribute), self::$namingSchemeMethods);
353
354 25
        if (method_exists($this, $setter) && is_callable([$this, $setter])) {
355 3
            $oldValue = $this->__get($attribute);
356 3
            $md5OldData = md5(serialize($this->data));
357 3
            $this->$setter($value);
358 3
            $changed = $md5OldData !== md5(serialize($this->data));
359
        } else {
360 22
            if (static::isValidatorEnabled()) {
361 6
                $error = static::validate($attribute, $value);
362 3
                if ($error instanceof Error) {
363 1
                    throw $error;
364
                }
365
            }
366
367 18
            $oldValue = $this->__get($attribute);
368 18
            $changed = (isset($this->data[$col]) ? $this->data[$col] : null) !== $value;
369 18
            $this->data[$col] = $value;
370
        }
371
372 21
        if ($changed) {
373 18
            $this->onChange($attribute, $oldValue, $this->__get($attribute));
374
        }
375 21
    }
376
377
    /**
378
     * Fill the entity with $data
379
     *
380
     * @param array $data
381
     * @param bool  $ignoreUnknown
382
     * @throws UnknownColumn
383
     */
384 3
    public function fill(array $data, $ignoreUnknown = false)
385
    {
386 3
        foreach ($data as $attribute => $value) {
387
            try {
388 3
                $this->__set($attribute, $value);
389 2
            } catch (UnknownColumn $e) {
390 2
                if (!$ignoreUnknown) {
391 3
                    throw $e;
392
                }
393
            }
394
        }
395 2
    }
396
397
    /**
398
     * Get related objects
399
     *
400
     * The difference between getRelated and fetch is that getRelated stores the fetched entities. To refresh set
401
     * $refresh to true.
402
     *
403
     * @param string $relation
404
     * @param bool   $refresh
405
     * @return mixed
406
     * @throws Exception\NoConnection
407
     * @throws Exception\NoEntity
408
     * @throws IncompletePrimaryKey
409
     * @throws InvalidConfiguration
410
     * @throws NoEntityManager
411
     * @throws UndefinedRelation
412
     */
413 11
    public function getRelated($relation, $refresh = false)
414
    {
415 11
        if ($refresh || !isset($this->relatedObjects[$relation])) {
416 9
            $this->relatedObjects[$relation] = $this->fetch($relation, true);
417
        }
418
419 11
        return $this->relatedObjects[$relation];
420
    }
421
422
    /**
423
     * Set $relation to $entity
424
     *
425
     * This method is only for the owner of a relation.
426
     *
427
     * @param string $relation
428
     * @param Entity $entity
429
     * @throws IncompletePrimaryKey
430
     * @throws InvalidRelation
431
     */
432 7
    public function setRelated($relation, Entity $entity = null)
433
    {
434 7
        $this::getRelation($relation)->setRelated($this, $entity);
435
436 4
        $this->relatedObjects[$relation] = $entity;
437 4
    }
438
439
    /**
440
     * Add relations for $relation to $entities
441
     *
442
     * This method is only for many-to-many relations.
443
     *
444
     * This method does not take care about already existing relations and will fail hard.
445
     *
446
     * @param string        $relation
447
     * @param Entity[]      $entities
448
     * @throws NoEntityManager
449
     */
450 8
    public function addRelated($relation, array $entities)
451
    {
452
        // @codeCoverageIgnoreStart
453
        if (func_num_args() === 3 && func_get_arg(2) instanceof EM) {
454
            trigger_error(
455
                'Passing EntityManager to addRelated is deprecated. Use ->setEntityManager() to overwrite',
456
                E_USER_DEPRECATED
457
            );
458
        }
459
        // @codeCoverageIgnoreEnd
460
461 8
        $this::getRelation($relation)->addRelated($this, $entities, $this->entityManager);
462 4
    }
463
464
    /**
465
     * Delete relations for $relation to $entities
466
     *
467
     * This method is only for many-to-many relations.
468
     *
469
     * @param string        $relation
470
     * @param Entity[]      $entities
471
     * @throws NoEntityManager
472
     */
473 8
    public function deleteRelated($relation, $entities)
474
    {
475
        // @codeCoverageIgnoreStart
476
        if (func_num_args() === 3 && func_get_arg(2) instanceof EM) {
477
            trigger_error(
478
                'Passing EntityManager to deleteRelated is deprecated. Use ->setEntityManager() to overwrite',
479
                E_USER_DEPRECATED
480
            );
481
        }
482
        // @codeCoverageIgnoreEnd
483
484 8
        $this::getRelation($relation)->deleteRelated($this, $entities, $this->entityManager);
485 4
    }
486
487
    /**
488
     * Resets the entity or $attribute to original data
489
     *
490
     * @param string $attribute Reset only this variable or all variables
491
     * @throws InvalidConfiguration
492
     */
493 8
    public function reset($attribute = null)
494
    {
495 8
        if (!empty($attribute)) {
496 3
            $col = static::getColumnName($attribute);
497 3
            if (isset($this->originalData[$col])) {
498 2
                $this->data[$col] = $this->originalData[$col];
499
            } else {
500 1
                unset($this->data[$col]);
501
            }
502 3
            return;
503
        }
504
505 5
        $this->data = $this->originalData;
506 5
    }
507
508
    /**
509
     * Save the entity to EntityManager
510
     *
511
     * @return Entity
512
     * @throws Exception\NoConnection
513
     * @throws Exception\NoEntity
514
     * @throws Exception\NotScalar
515
     * @throws Exception\UnsupportedDriver
516
     * @throws IncompletePrimaryKey
517
     * @throws InvalidConfiguration
518
     * @throws InvalidName
519
     * @throws NoEntityManager
520
     */
521 12
    public function save()
522
    {
523
        // @codeCoverageIgnoreStart
524
        if (func_num_args() === 1 && func_get_arg(0) instanceof EM) {
525
            trigger_error(
526
                'Passing EntityManager to save is deprecated. Use ->setEntityManager() to overwrite',
527
                E_USER_DEPRECATED
528
            );
529
        }
530
        // @codeCoverageIgnoreEnd
531
532 12
        $inserted = false;
533 12
        $updated = false;
534
535
        try {
536
            // this may throw if the primary key is auto incremented but we using this to omit duplicated code
537 12
            if (!$this->entityManager->sync($this)) {
538 2
                $this->entityManager->insert($this, false);
539 2
                $inserted = true;
540 5
            } elseif ($this->isDirty()) {
541 4
                $this->preUpdate();
542 4
                $this->entityManager->update($this);
543 7
                $updated = true;
544
            }
545 5
        } catch (IncompletePrimaryKey $e) {
546 5
            if (static::isAutoIncremented()) {
547 4
                $this->prePersist();
548 4
                $id = $this->entityManager->insert($this);
549 4
                $this->data[static::getColumnName(static::getPrimaryKeyVars()[0])] = $id;
550 4
                $inserted = true;
551
            } else {
552 1
                throw $e;
553
            }
554
        }
555
556 11
        if ($inserted || $updated) {
557 10
            $inserted && $this->postPersist();
558 10
            $updated && $this->postUpdate();
559 10
            $this->entityManager->sync($this, true);
560
        }
561
562 11
        return $this;
563
    }
564
565
    /**
566
     * Checks if entity or $attribute got changed
567
     *
568
     * @param string $attribute Check only this variable or all variables
569
     * @return bool
570
     * @throws InvalidConfiguration
571
     */
572 18
    public function isDirty($attribute = null)
573
    {
574 18
        if (!empty($attribute)) {
575 4
            $col = static::getColumnName($attribute);
576 4
            return (isset($this->data[$col]) ? $this->data[$col] : null) !==
577 4
                   (isset($this->originalData[$col]) ? $this->originalData[$col] : null);
578
        }
579
580 15
        ksort($this->data);
581 15
        ksort($this->originalData);
582
583 15
        return serialize($this->data) !== serialize($this->originalData);
584
    }
585
586
    /**
587
     * Empty event handler
588
     *
589
     * Get called when something is changed with magic setter.
590
     *
591
     * @param string $attribute The variable that got changed.merge(node.inheritedProperties)
592
     * @param mixed  $oldValue The old value of the variable
593
     * @param mixed  $value The new value of the variable
594
     */
595 6
    public function onChange($attribute, $oldValue, $value)
3 ignored issues
show
Unused Code introduced by
The parameter $attribute is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $oldValue is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $value is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
596
    {
597 6
    }
598
599
    /**
600
     * Empty event handler
601
     *
602
     * Get called when the entity get initialized.
603
     *
604
     * @param bool $new Whether or not the entity is new or from database
605
     */
606 112
    public function onInit($new)
607
    {
608 112
    }
609
610
    /**
611
     * Empty event handler
612
     *
613
     * Get called before the entity get updated in database.
614
     */
615 3
    public function preUpdate()
616
    {
617 3
    }
618
619
    /**
620
     * Empty event handler
621
     *
622
     * Get called before the entity get inserted in database.
623
     */
624 3
    public function prePersist()
625
    {
626 3
    }
627
628
629
    // DEPRECATED stuff
630
631
    /**
632
     * Empty event handler
633
     *
634
     * Get called after the entity got inserted in database.
635
     */
636 5
    public function postPersist()
637
    {
638 5
    }
639
640
    /**
641
     * Empty event handler
642
     *
643
     * Get called after the entity got updated in database.
644
     */
645 3
    public function postUpdate()
646
    {
647 3
    }
648
649
    /**
650
     * Fetches related objects
651
     *
652
     * For relations with cardinality many it returns an EntityFetcher. Otherwise it returns the entity.
653
     *
654
     * It will throw an error for non owner when the key is incomplete.
655
     *
656
     * @param string        $relation      The relation to fetch
657
     * @param bool          $getAll
658
     * @return Entity|Entity[]|EntityFetcher
659
     * @throws NoEntityManager
660
     */
661 19
    public function fetch($relation, $getAll = false)
662
    {
663
        // @codeCoverageIgnoreStart
664
        if (func_num_args() === 3 && ($getAll instanceof EM || $getAll === null)) {
665
            $getAll = func_get_arg(2);
666
            trigger_error(
667
                'Passing EntityManager to fetch is deprecated. Use ->setEntityManager() to overwrite',
668
                E_USER_DEPRECATED
669
            );
670
        }
671
        // @codeCoverageIgnoreEnd
672
673 19
        $relation = $this::getRelation($relation);
674
675 19
        if ($getAll) {
676 4
            return $relation->fetchAll($this, $this->entityManager);
677
        } else {
678 15
            return $relation->fetch($this, $this->entityManager);
679
        }
680
    }
681
682
    /**
683
     * Get the primary key
684
     *
685
     * @return array
686
     * @throws IncompletePrimaryKey
687
     */
688 38
    public function getPrimaryKey()
689
    {
690 38
        $primaryKey = [];
691 38
        foreach (static::getPrimaryKeyVars() as $attribute) {
692 38
            $value = $this->$attribute;
693 38
            if ($value === null) {
694 4
                throw new IncompletePrimaryKey('Incomplete primary key - missing ' . $attribute);
695
            }
696 36
            $primaryKey[$attribute] = $value;
697
        }
698 34
        return $primaryKey;
699
    }
700
701
    /**
702
     * Get current data
703
     *
704
     * @return array
705
     * @internal
706
     */
707 20
    public function getData()
708
    {
709 20
        return $this->data;
710
    }
711
712
    /**
713
     * Set new original data
714
     *
715
     * @param array $data
716
     * @internal
717
     */
718 18
    public function setOriginalData(array $data)
719
    {
720 18
        $this->originalData = $data;
721 18
    }
722
723
    /**
724
     * String representation of data
725
     *
726
     * @link http://php.net/manual/en/serializable.serialize.php
727
     * @return string
728
     */
729 2
    public function serialize()
730
    {
731 2
        return serialize([$this->data, $this->relatedObjects]);
732
    }
733
734
    /**
735
     * Constructs the object
736
     *
737
     * @link http://php.net/manual/en/serializable.unserialize.php
738
     * @param string $serialized The string representation of data
739
     */
740 3
    public function unserialize($serialized)
741
    {
742 3
        list($this->data, $this->relatedObjects) = unserialize($serialized);
743 3
        $this->entityManager = EM::getInstance(static::class);
744 3
        $this->onInit(false);
745 3
    }
746
747
    /**
748
     * @return string
749
     * @deprecated use getOption from EntityManager
750
     * @codeCoverageIgnore deprecated
751
     */
752
    public static function getTableNameTemplate()
753
    {
754
        return static::$tableNameTemplate;
755
    }
756
757
    /**
758
     * @param string $tableNameTemplate
759
     * @deprecated use setOption from EntityManager
760
     * @codeCoverageIgnore deprecated
761
     */
762
    public static function setTableNameTemplate($tableNameTemplate)
763
    {
764
        static::$tableNameTemplate = $tableNameTemplate;
765
    }
766
767
    /**
768
     * @return string
769
     * @deprecated use getOption from EntityManager
770
     * @codeCoverageIgnore deprecated
771
     */
772
    public static function getNamingSchemeTable()
773
    {
774
        return static::$namingSchemeTable;
775
    }
776
777
    /**
778
     * @param string $namingSchemeTable
779
     * @deprecated use setOption from EntityManager
780
     * @codeCoverageIgnore deprecated
781
     */
782
    public static function setNamingSchemeTable($namingSchemeTable)
783
    {
784
        static::$namingSchemeTable = $namingSchemeTable;
785
    }
786
787
    /**
788
     * @return string
789
     * @deprecated use getOption from EntityManager
790
     * @codeCoverageIgnore deprecated
791
     */
792
    public static function getNamingSchemeColumn()
793
    {
794
        return static::$namingSchemeColumn;
795
    }
796
797
    /**
798
     * @param string $namingSchemeColumn
799
     * @deprecated use setOption from EntityManager
800
     * @codeCoverageIgnore deprecated
801
     */
802
    public static function setNamingSchemeColumn($namingSchemeColumn)
803
    {
804
        static::$namingSchemeColumn = $namingSchemeColumn;
805
    }
806
807
    /**
808
     * @return string
809
     * @deprecated use getOption from EntityManager
810
     * @codeCoverageIgnore deprecated
811
     */
812
    public static function getNamingSchemeMethods()
813
    {
814
        return static::$namingSchemeMethods;
815
    }
816
817
    /**
818
     * @param string $namingSchemeMethods
819
     * @deprecated use setOption from EntityManager
820
     * @codeCoverageIgnore deprecated
821
     */
822
    public static function setNamingSchemeMethods($namingSchemeMethods)
823
    {
824
        static::$namingSchemeMethods = $namingSchemeMethods;
825
    }
826
}
827