<?php

namespace RadiusTheme\RadiusBooking\ExportImport\Exporters;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

use RadiusTheme\RadiusBooking\ExportImport\Contracts\ExporterInterface;
use RadiusTheme\RadiusBooking\Models\Category;

/**
 * Class CategoryExporter
 *
 * Exports service categories.
 *
 * @package RadiusTheme\RadiusBooking\ExportImport\Exporters
 */
class CategoryExporter implements ExporterInterface {

	/**
	 * {@inheritDoc}
	 */
	public function getModuleName(): string {
		return 'category';
	}

	/**
	 * {@inheritDoc}
	 */
	public function count(): int {
		return Category::query()->count();
	}

	/**
	 * {@inheritDoc}
	 */
	public function export( int $offset = 0, int $limit = 500 ): array {
		$rows    = Category::query()->offset( $offset )->limit( $limit )->get();
		$records = array();

		foreach ( $rows as $row ) {
			$model     = Category::hydrate( $row );
			$records[] = $model->toArray();
		}

		return $records;
	}

	/**
	 * {@inheritDoc}
	 */
	public function getDependencies(): array {
		return array();
	}
}
