<?php
/**
 * Client Service Provider Class
 *
 * @package Easy_Invoice
 * @subpackage Providers
 */

namespace EasyInvoice\Providers;

use EasyInvoice\Interfaces\ClientRepositoryInterface;
use EasyInvoice\Repositories\ClientRepository;

/**
 * ClientServiceProvider Class
 * 
 * Handles registration of client-related services.
 */
class ClientServiceProvider {
    /**
     * The repository instance
     *
     * @var ClientRepositoryInterface
     */
    protected static $repository = null;
    
    /**
     * Register client services
     */
    public function register() {
        // Register actions and filters
        add_action('after_setup_theme', [$this, 'registerClientRole']);
        
        // Register client repository
        $this->registerClientRepository();
    }
    
    /**
     * Register client role if it doesn't exist
     */
    public function registerClientRole() {
        $role = get_role('customer');
        
        if (!$role) {
            add_role('customer', __('Customer', 'easy-invoice'), [
                'read' => true,
            ]);
        }
    }
    
    /**
     * Register client repository
     */
    protected function registerClientRepository() {
        // Create and store the repository instance
        self::$repository = new ClientRepository();
    }
    
    /**
     * Get the client repository
     *
     * @return ClientRepositoryInterface The client repository
     */
    public static function getClientRepository() {
        // Create the repository if it doesn't exist
        if (self::$repository === null) {
            self::$repository = new ClientRepository();
        }
        
        return self::$repository;
    }
} 