PluginProbe
QuadMenu – Mega Menu / 3.3.7
QuadMenu – Mega Menu v3.3.7
3.3.8 3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 88 releases
quadmenu / vendor / franmastromarino / wp-orm / src / Builder / SingleRepositoryBuilder.php

SingleRepositoryBuilder.php in QuadMenu – Mega Menu 3.3.7, at vendor/franmastromarino/wp-orm/src/Builder/SingleRepositoryBuilder.php

44 lines 963 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace QuadLayers\WP_Orm\Builder;
4
5 use QuadLayers\WP_Orm\Factory\SingleFactory;
6 use QuadLayers\WP_Orm\Mapper\SingleMapper;
7 use QuadLayers\WP_Orm\Repository\SingleRepository;
8
9 class SingleRepositoryBuilder
10 {
11 /**
12 * @var string
13 */
14 private $table;
15
16 /**
17 * @var string
18 */
19 private $entityClass;
20
21 public function setTable(string $table): self
22 {
23 $this->table = $table;
24 return $this;
25 }
26
27 public function setEntity(string $entityClass): self
28 {
29 if (!class_exists($entityClass)) {
30 throw new \InvalidArgumentException("Class '{$entityClass}' does not exist.");
31 }
32
33 $this->entityClass = $entityClass;
34 return $this;
35 }
36
37 public function getRepository(): SingleRepository
38 {
39 $factory = new SingleFactory($this->entityClass);
40 $mapper = new SingleMapper($factory);
41 return new SingleRepository($mapper, $this->table);
42 }
43 }
44