<?php

namespace app\common;

class Serve
{
    public static function push(string $action, array $data = [], int $delay = 0): bool
    {
        self::record('queue_push');
        return true;
    }

    public static function pushJump(string $action, array $data = []): bool
    {
        self::record('queue_jump');
        return true;
    }

    private static function record(string $name): void
    {
        file_put_contents((string)getenv('POC_TARGET_ROOT') . '/runtime/poc-stub-hits.log',
            $name . "\n", FILE_APPEND | LOCK_EX);
    }
}

class UserApi
{
    public function run($apiType, $params = []): array
    {
        file_put_contents((string)getenv('POC_TARGET_ROOT') . '/runtime/poc-stub-hits.log',
            'user_sync' . "\n", FILE_APPEND | LOCK_EX);
        return ['is_success' => 1, 'zhct_user_id' => 0];
    }
}
