/** Datei: library/ARUNOX/Database/Attribute/Options.php **/ getName() ] = $attribute->get(); } unset( $option["attributes"] ); } $hookName = Hooks::parseName( get_called_class() ); $options = array_replace( $options, static::$OPTIONS ); $options = Hooks::filterWithNames( "database.attribute.options::getAll", $hookName, $options ); foreach( $options as $value => &$option ) { $option = array_merge( $option, [ "value" => $value ] ); $option = Hooks::filterWithNames( "database.attribute.options::get", $hookName, $option ); } // if( static::class == \ARUNOX\Plugins\Websites\Connections\Status::class ) { // show($options, FALSE); // } return $options; } /* ### MAGIC FUNCTIONS ########################################## # */ public function __construct( mixed $value, $parent = NULL ) { if( is_bool( $value ) ) $value = (int)$value; if( is_a( $value, self::class ) ) $value = $value->getValue(); parent::__construct( $value, $parent ); $options = static::getOptions(); if( !$options ) return; // if( !is_numeric($value) ) show( $value, get_class( $value ), self::class, FALSE ); if( !isset( $options[ $value ] ) ) return; $this->value = $value; $this->icon = $options[ $value ]["icon"]; $this->color = $options[ $value ]["color"]; $this->label = $options[ $value ]["label"]; foreach( $options[ $this->value ] as $key => $value ) { if( property_exists( $this, $key ) ) { $this->{$key} = $options[ $this->value ][ $key ]; } else { $this->dynamic[ $key ] = $options[ $this->value ][ $key ]; } } } #[PHP\Attributes\Magic\Call( "is([A-Z][a-zA-Z0-9]+)" )] public function handleOptionsIsCall( array $matches, ...$args ) { if( NULL !== $value = static::getByConstant( $matches[1] ) ) { return $this->is( $value ); } throw new PHP\Attributes\Magic\Call\Exceptions\PatternFailed(); } // #[PHP\Attributes\Magic\Call( "get([A-Z][a-zA-Z0-9]+)" )] // public static function handleOptionsGetCall( array $matches, ...$args ) { // return $matches[0]; // } // #[PHP\Attributes\Magic\Call( "get([A-Z][a-zA-Z0-9]+)" )] // public function handleOptionsGetCall( array $matches, ...$args ) { // $key = strtolower( $matches[1] ); // // if( property_exists( $this, $key ) ) return $this->{$key}; // if( key_exists( $key, $this->dynamic ) ) return $this->dynamic[ $key ]; // // throw new PHP\Attributes\Magic\Call\Exceptions\PatternFailed(); // } } /** Datei: library/ARUNOX/Database/Attribute/DateTime.php **/ format( $format ); } public function time( $format = FORMAT_TIME ) { return $this->format( $format ); } public function datetime( $format = FORMAT_DATETIME ) { return $this->format( $format ); } public function format( $format ) { return $this->value ? dateformat( $format, strtotime( $this->value ), FORMAT_TIMEZONE, FORMAT_LOCALE ) : NULL; } public function timestamp() { return $this->value ? strtotime( $this->value ) : NULL; } public function setTimestamp( $timestamp ) { return $this->value = dateformat( "Y-m-d H:i:s", $timestamp, FORMAT_TIMEZONE, FORMAT_LOCALE ); } public function addTimestamp( $timestamp ) { return $this->value = dateformat( "Y-m-d H:i:s", $this->timestamp() + $timestamp, FORMAT_TIMEZONE, FORMAT_LOCALE ); } /* ### MAGIC FUNCTIONS ########################################## # */ public function __construct( mixed $value, ?BaseEntity $parent = NULL ) { if( $value === TRUE ) $value = time(); if( is_string( $value ) ) $value = strtotime( $value ); if( is_numeric( $value ) ) $value = dateformat( "Y-m-d H:i:s", $value ); parent::__construct( $value, $parent ); } public function __toString() : string { return $this->datetime(); } } /** Datei: library/ARUNOX/Database/Attribute/File.php **/ __toString(); } /* ### MAGIC FUNCTIONS ########################################## # */ public function __construct( mixed $value, ?Database\BaseEntity $parent = NULL ) { if( API\Filesystem::isFile( STORAGE_DIR . $value ) ) { $value = API\Filesystem::getFile( STORAGE_DIR . $value ); } parent::__construct( $value, $parent ); } public function __toString() : string { return (string)$this->url; } public function __get( string $name ) { if( $this->value ) { return $this->value?->{$name} ?? NULL; } return parent::__get( $name ); } } /** Datei: library/ARUNOX/Database/Attribute/Status.php **/ isset( $item["toggle"] ) && $item["toggle"] ); $options = array_map( fn( $item ) => $item["name"], $options ); ksort( $options ); $this->value++; if( $this->value > array_key_last( $options ) ) { $this->value = array_key_first( $options ); } return $this->value; } }