index/src/Data/MariaDB/MariaDBCharacterSetInfo.php

89 lines
2.2 KiB
PHP

<?php
// MariaDBCharacterSetInfo.php
// Created: 2021-05-02
// Updated: 2024-08-03
namespace Index\Data\MariaDB;
/**
* Contains information about the character set.
*
* @see https://www.php.net/manual/en/mysqli.get-charset
*/
class MariaDBCharacterSetInfo {
/**
* Creates a new character set info instance.
*
* @param object $charSet Anonymous object containing the information.
* @return MariaDBCharacterSetInfo Character set information class.
*/
public function __construct(
private object $charSet
) {}
/**
* Returns the name of the current character set.
*
* @return string Character set name.
*/
public function getCharacterSet(): string {
return $this->charSet->charset ?? '';
}
/**
* Returns the name of the default collation.
*
* @return string Default collation name.
*/
public function getDefaultCollation(): string {
return $this->charSet->collation ?? '';
}
/**
* Returns the path to the directory the charcter was read from.
* May be empty for built-in character sets.
*
* @return string Source directory.
*/
public function getDirectory(): string {
return $this->charSet->dir ?? '';
}
/**
* Returns the minimum character width in bytes for this character set.
*
* @return int Minimum character width in bytes.
*/
public function getMinimumWidth(): int {
return $this->charSet->min_length ?? 0;
}
/**
* Returns the maximum character width in bytes for this character set.
*
* @return int Maximum character width in bytes.
*/
public function getMaximumWidth(): int {
return $this->charSet->max_length ?? 0;
}
/**
* Returns the internal numeric identifier for this character set.
*
* @return int Character set identifier.
*/
public function getId(): int {
return $this->charSet->number ?? 0;
}
/**
* Returns the character set status.
*
* Whatever that means. Given the (?) in the official documentation, not even they know.
*
* @return int Character set status.
*/
public function getState(): int {
return $this->charSet->state ?? 0;
}
}