lightfly/finance

China finance package for php

0.2.4 2020-05-31 04:39 UTC

This package is auto-updated.

Last update: 2024-10-29 05:46:52 UTC


README

金融数据服务

GitHub Packagist Version Build Status

Quality gate

安装

composer require guzzlehttp/guzzle
composer require lightfly/finance

使用

基本使用

<?php
use GuzzleHttp\Client;
use Lightfly\Finance\HttpClient;
use Lightfly\Finance\Stock\Stock;

$httpClient = new HttpClient(new Client());

$stock = new Stock($httpClient);
$data = $stock->HS300();

var_dump($data);

高级

如果不喜欢 guzzle 或者主机配置的原因,可以替换 http client 的实现,只要继承 HttpClientInterface 实现相应的 get 和 post 方法即可,示例:

class AnotherHttpClient implements HttpClientInterface
{
    public function get($url, $options = [])
    {
        return file_get_contents($url);
    }
}

$httpClient = new AnotherHttpClient();

$stock = new Stock($httpClient);
$data = $stock->HS300();

var_dump($data);

Run tests

bin/phpspec run