for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types = 1);
namespace SimpleCrud\Scheme;
use PDO;
/**
* Class to autodetect the scheme
*/
final class Scheme implements SchemeInterface
{
private $engine;
public function __construct(PDO $pdo)
$engine = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME);
switch ($engine) {
case 'mysql':
$this->scheme = new Mysql($pdo);
scheme
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
break;
case 'sqlite':
$this->scheme = new Sqlite($pdo);
default:
throw new RuntimeException(sprintf('Invalid engine type: %s', $engine));
}
public function getTables(): array
return $this->scheme->getTables();
public function getTableFields(string $table): array
return $this->scheme->getTableFields($table);
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: