1 <?php 2 3 namespace Laminas\Feed\PubSubHubbub\Model; 4 5 use Laminas\Db\TableGateway\TableGateway; 6 use Laminas\Db\TableGateway\TableGatewayInterface; 7 8 use function array_pop; 9 use function explode; 10 use function strtolower; 11 12 class AbstractModel 13 { 14 /** 15 * Laminas\Db\TableGateway\TableGatewayInterface instance to host database methods 16 * 17 * @var TableGatewayInterface 18 */ 19 protected $db; 20 21 public function __construct(?TableGatewayInterface $tableGateway = null) 22 { 23 if ($tableGateway === null) { 24 $parts = explode('\\', static::class); 25 $table = strtolower(array_pop($parts)); 26 $this->db = new TableGateway($table, null); 27 } else { 28 $this->db = $tableGateway; 29 } 30 } 31 }