Skip to content
Snippets Groups Projects
Commit db3afdc8 authored by Milad Emadi's avatar Milad Emadi
Browse files

abstract $tables

parent 1fe13a89
Branches
Tags 1.4.5
No related merge requests found
......@@ -8,7 +8,7 @@
"framework": "composer",
"application": "package",
"private": false,
"version": "1.3.4",
"version": "1.4.5",
"author": "Amir Abolhasani",
"license": "MIT"
}
\ No newline at end of file
......@@ -4,11 +4,9 @@ namespace Namirasoft\Core\meta;
abstract class BaseMetaDatabase
{
public array $tables = [];
public function forEachTable(callable $handler) // : ?mixed
public function forEachTable(callable $handler): mixed
{
foreach ($this->tables as $key => $element) {
foreach ($this->getTables() as $key => $element) {
$ans = $handler($element);
if ($ans !== null) {
return $ans;
......@@ -17,19 +15,11 @@ abstract class BaseMetaDatabase
return null;
}
public function getTables(): array
{
$ans = [];
$this->forEachTable(function ($table) use (&$ans) {
$ans[] = $table;
return null;
});
return $ans;
}
abstract public function getTables(): array;
public function hasTable(string $name): bool
{
return isset($this->tables[$name]);
return isset($this->getTables()[$name]);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment