Passed
Branch feature-validator (2224d0)
by Thomas
03:15
created

Entity::fetch()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 5

Importance

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