for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types = 1);
namespace Puzzle\QueryBuilder\Queries\Snippets;
use Puzzle\QueryBuilder\Snippet;
class TableName implements Snippet
{
private
$tableName,
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.
$alias;
public function __construct(?string $tableName, ?string $alias = null)
if(empty($tableName))
throw new \InvalidArgumentException('Empty table name.');
}
$this->tableName = $tableName;
$this->alias = (string) $alias;
public function toString(): string
if(empty($this->alias))
return $this->tableName;
return sprintf('%s AS %s', $this->tableName, $this->alias);
public function getName(): string
public function getAlias(): string
return $this->alias;
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.