grafstorm/hitta_php_package

Hitta.se PHP 包

0.1.0 2021-05-26 21:02 UTC

This package is not auto-updated.

Last update: 2024-09-26 13:26:32 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

开发中的包
围绕 Hitta.se 提供的 API 的流畅包装。使用示例

$hitta = new Hitta('::api-user::', '::api-key::');
$result = $hitta->companies()
    ->what('Empire')
    ->where('Deathstar')
    ->find();

foreach($result->companies as $company) {
    echo $company->displayName . "\n";
}

需求

需要 PHP 8。

安装

您可以通过 composer 安装此包

composer require grafstorm/hitta_php_package

使用

// Hitta.se API Wrapper as a Laravel Package
// Search for Swedish companies and people

// Create a new instance of the API wrapper.
$hitta = new Hitta('::api-user::', '::api-key::');

// Combined search. You can also explicitly call Hitta::combined()
$hitta->what('Luke Skywalker')
  ->where('Kiruna')
  ->find();
  
$result = $hitta->combined()
  ->what('Empire')
  ->where('Deathstar')
  ->find();

foreach($result->companies as $company) {
  echo $company->displayName . "\n";
}

foreach($result->people as $person) {
  echo $person->displayName . "\n";
}

// Only Search for people
$hitta->people()
  ->what('Luke Skywalker')
  ->find();
  
// Only Search for companies
$hitta->companies()
  ->what('Empire')
  ->find();
  
// Optional search parameters
$hitta->companies()
  ->what('Luke Skywalker')
  ->where('Kiruna')
  ->pageNumber(1)
  ->pageSize(10)
  ->rangeFrom(100)
  ->rangeTo(150)
  ->find();

// Example of Fetching details of a company or person with findPerson and findCompany.
$result = $hitta->combined()
  ->what('Skywalker')
  ->find();
  
$personId = collect($result->people)->first()->id;
$companyId = collect($result->companies)->first()->id;

$hitta->findPerson($personId);
$hitta->findCompany($companyId);

测试

除非您在测试环境中提供它们,否则需要正确 API 密钥的测试将被跳过。

composer test

变更日志

有关最近更改的更多信息,请参阅 变更日志

贡献

请参阅 CONTRIBUTING 以获取详细信息。

安全漏洞

有关如何报告安全漏洞的详细信息,请参阅 我们的安全策略

致谢

许可证

MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件