*/ private $state = array(); /** * Creation timestamp, GMT. * * @var string */ private $created_at; /** * Constructor. * * @param string $module_id Module id. * @param int[] $object_ids Object ids in scope. */ public function __construct( string $module_id, array $object_ids = array() ) { $this->id = uniqid( 'transtrix_', true ); $this->module_id = $module_id; $this->object_ids = array_values( array_map( 'intval', $object_ids ) ); $this->created_at = gmdate( 'c' ); } /** * Job id. * * @return string */ public function id(): string { return $this->id; } /** * Module id. * * @return string */ public function module_id(): string { return $this->module_id; } /** * Object ids in scope. * * @return int[] */ public function object_ids(): array { return $this->object_ids; } /** * Replace the object ids, so before_export() can widen or narrow the job. * * @param int[] $object_ids Object ids. * @return void */ public function set_object_ids( array $object_ids ): void { $this->object_ids = array_values( array_map( 'intval', $object_ids ) ); } /** * Read a state value. * * @param string $key State key. * @param mixed $fallback Fallback when unset. * @return mixed */ public function get_state( string $key, $fallback = null ) { return array_key_exists( $key, $this->state ) ? $this->state[ $key ] : $fallback; } /** * Write a state value. * * @param string $key State key. * @param mixed $value Value. * @return void */ public function set_state( string $key, $value ): void { $this->state[ $key ] = $value; } /** * Creation timestamp. * * @return string */ public function created_at(): string { return $this->created_at; } }