Passed
Pull Request — master (#41)
by Thomas
03:07
created

Entity::save()   C

Complexity

Conditions 11
Paths 78

Size

Total Lines 43
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 22
CRAP Score 11

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 43
ccs 22
cts 22
cp 1
rs 5.2653
cc 11
eloc 28
nc 78
nop 0
crap 11

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