Add classes and tests from common project
This commit is contained in:
32
src/Configuration.php
Normal file
32
src/Configuration.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace BitBadger\PDODocument;
|
||||
|
||||
/**
|
||||
* Common configuration for the document library
|
||||
*/
|
||||
class Configuration
|
||||
{
|
||||
/** @var string The name of the ID field used in the database (will be treated as the primary key) */
|
||||
private static string $_idField = 'id';
|
||||
|
||||
/**
|
||||
* Configure the ID field used by the library
|
||||
*
|
||||
* @param string $name The name of the ID field within each document
|
||||
*/
|
||||
public static function useIdField(string $name): void
|
||||
{
|
||||
self::$_idField = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the ID field for documents within this library
|
||||
*
|
||||
* @return string The configured ID field
|
||||
*/
|
||||
public static function idField(): string
|
||||
{
|
||||
return self::$_idField;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user