Compare commits

...

33 commits

Author SHA1 Message Date
8937dfc8d7 Merge pull request 'Pix Lib and Validations' (#2) from bacarin/phpkore:master into master
Reviewed-on: #2
2025-07-11 18:33:16 +00:00
4a3d0684e8 documentation: updating to show 'environment' variable 2025-07-11 15:29:29 -03:00
e34c057087 Environment variable for Kore Class 2025-07-11 15:28:25 -03:00
22a5288af5 Removing testRequest function from Kore class 2025-07-11 15:23:51 -03:00
43f296585b update gitignore: ignoring test.php file 2025-07-11 15:20:26 -03:00
155ac8fd42 pixEstatico documentation 2025-07-11 14:41:29 -03:00
3758d3f1d0 function pixCobrancaEstatico 2025-07-07 18:17:25 -03:00
1eea65bef7 Index on docs 2025-07-07 15:05:13 -03:00
847da21c02 PixTroco e PixSaque documentation 2025-07-07 14:24:13 -03:00
5da8edc426 Pix Cobrança Dinâmico Imediata Troco Com Valor 2025-07-04 17:28:56 -03:00
d26f5850f9 Pix Cobrança Dinâmico Imediata Troco Sem Valor 2025-07-04 17:27:44 -03:00
a9abbfe932 setted server url as a class property and consumes it in every function 2025-07-04 16:57:17 -03:00
4cf3ecc867 Pix Cobrança Dinâmico Imediata Saque Com Valor 2025-07-04 16:49:35 -03:00
96769b84c5 Pix Cobrança Dinâmico Imediata Saque Sem Valor 2025-07-04 16:44:14 -03:00
df99b098e3 Started documentation 2025-07-04 11:48:06 -03:00
876ea2b868 Removing old package to made validation 2025-07-04 11:47:50 -03:00
507e68a153 Rework to be compatible with PHP 7.* 2025-07-04 11:45:50 -03:00
480cc208d7 Rework to be compatible with PHP 7.* 2025-07-04 11:44:27 -03:00
de8c7b4ac4 rework on rules 2025-07-04 11:43:43 -03:00
2e33469987 Custom validator created with some functions 2025-07-04 11:43:22 -03:00
e2c3372ab1 changing pix function names to describe it better 2025-07-03 18:49:54 -03:00
c4702e0c93 generating pix with and without value 2025-07-03 18:44:16 -03:00
337f1945ff Validation library and rules to generate pix 2025-07-03 18:41:58 -03:00
b2d14abbce validation rules 2025-07-03 18:40:11 -03:00
a91b6e8650 rules file to manage required payloads 2025-07-03 17:15:31 -03:00
8af086e834 ignoring some files 2025-07-03 17:15:09 -03:00
44e9ac4f34 add main parameters to pixCobrançaImediata function on Pix 2025-07-03 17:13:51 -03:00
0bcfded7c7 add drone as parameter to Kore main lib 2025-07-03 17:13:01 -03:00
bfe904943c first steps with Pix class 2025-06-24 16:56:49 -03:00
17ebac8300 improvements 2025-06-24 16:30:38 -03:00
3472b19591 Identation and fixes to load keys 2025-06-24 14:41:29 -03:00
be5a68f217 install phpseclib and create function to sign every body request 2025-06-13 16:25:04 -03:00
37aab36cd9 add gitignore and remove vendor folder 2025-06-13 16:24:38 -03:00
17 changed files with 938 additions and 774 deletions

6
.gitignore vendored Normal file
View file

@ -0,0 +1,6 @@
vendor/*
composer.lock
*.key
*.pub
index.php
tests.php

290
README.md Normal file
View file

@ -0,0 +1,290 @@
## KORE PHP LIB ##
## Índice
- [Classe: `PIX`](#classe-pix)
- [Função: `pixCobrancaDinamicoImediataSemValor`](#função-pixcobrancadinamicoimediatasemvalor)
- [Função: `pixCobrancaDinamicoImediataComValor`](#função-pixcobrancadinamicoimediatacomvalor)
- [Função: `pixCobrancaDinamicoImediataSaqueComValor`](#função-pixcobrancadinamicoimediatasaquecomvalor)
- [Função: `pixCobrancaDinamicoImediataSaqueSemValor`](#função-pixcobrancadinamicoimediatasaquesemvalor)
- [Função: `pixCobrancaDinamicoImediataTrocoComValor`](#função-pixcobrancadinamicoimediatatrococomvalor)
- [Função: `pixCobrancaDinamicoImediataTrocoSemValor`](#função-pixcobrancadinamicoimediatatrocosemvalor)
- [Função: `pixCobrancaEstatico`](#função-pixcobrancaestatico)
### Classe: `PIX`
**Descrição:**
Classe padrão para consumo das funções de PIX do Kore, utilizado para gerar cobranças, transferir valores e etc.
**Como Usar**
```php
$class = new \Kontrl\PhpKore\Pix($priv, $drone, $environment);
```
**Parâmetros:**
| Nome | Tipo | Obrigatório | Descrição |
|----------------|--------|-------------|--------------------------------------------------------------------------|
| `$priv` | string | Sim | Chave privada para assinatura da requisição |
| `$drone` | string | Sim | ID do drone gerado e fornecido pela Kontrl |
| `$environment` | string | Não | Ambiente a ser utilizado - Aceito: **PROD** ou **DEV** - Padrão: **DEV** |
### Função: `pixCobrancaDinamicoImediataSemValor`
**Descrição:**
Gera uma cobrança PIX dinâmica e imediata sem valor predefinido, ou com valor sugerido. O usuário pagador poderá alterar o valor na hora do pagamento.
**Como usar:**
```php
$class = new \Kontrl\PhpKore\Pix($priv, $drone, 'DEV');
$class->pixCobrancaDinamicoImediataSemValor($dados);
```
**Parâmetros:**
| Nome | Tipo | Obrigatório | Padrão | Descrição |
|----------|-------|-------------|--------|-----------------------------------------------------------------|
| `$dados` | array | Sim | — | Um array com os dados a serem enviados para geração da cobrança |
**Dados:**
| Chave | Tipo | Obrigatório | Descrição | Exemplo |
|----------------------|--------|-------------------------------------------|--------------------------------|-------------------------|
| `expiracao` | int | Sim | Tempo de expiração em segundos | `3600` |
| `devedor.documento` | string | Não | Documento do pagador | `"09432312054"` |
| `devedor.nome` | string | Não, somente se o documento for informado | Nome do pagador | `"Fulano da Silva"` |
| `valor` | int | Não | Valor sugerido | `10000` (R$100,00) |
| `chave` | string | Sim | Chave Pix de destino | `"12345678911"` |
| `txid` | string | Sim | Identificador da transação | `"098765432111"` |
| `solicitacaoPagador` | string | Não | Mensagem opcional ao pagador | `"Mensagem ao usuário"` |
**Retorno:**
Tipo: `array`
**Notas adicionais:**
- Lança `Exception` se algum dado obrigatório do array estiver vazio ou inválido.
### Função: `pixCobrancaDinamicoImediataComValor`
**Descrição:**
Gera uma cobrança PIX dinâmica e imediata com valor predefinido, o usuário pagador não poderá alterar o valor ao efetuar o pagamento.
**Como usar:**
```php
$class = new \Kontrl\PhpKore\Pix($priv, $drone, 'DEV');
$class->pixCobrancaDinamicoImediataComValor($dados);
```
**Parâmetros:**
| Nome | Tipo | Obrigatório | Padrão | Descrição |
|----------|-------|-------------|--------|-----------------------------------------------------------------|
| `$dados` | array | Sim | — | Um array com os dados a serem enviados para geração da cobrança |
**Dados:**
| Chave | Tipo | Obrigatório | Descrição | Exemplo |
|----------------------|--------|-------------------------------------------|--------------------------------|-------------------------|
| `expiracao` | int | Sim | Tempo de expiração em segundos | `3600` |
| `devedor.documento` | string | Não | Documento do pagador | `"09432312054"` |
| `devedor.nome` | string | Não, somente se o documento for informado | Nome do pagador | `"Fulano da Silva"` |
| `valor` | int | Sim | Valor sugerido | `10000` (R$100,00) |
| `chave` | string | Sim | Chave Pix de destino | `"12345678911"` |
| `txid` | string | Sim | Identificador da transação | `"098765432111"` |
| `solicitacaoPagador` | string | Não | Mensagem opcional ao pagador | `"Mensagem ao usuário"` |
**Retorno:**
Tipo: `array`
**Notas adicionais:**
- Lança `Exception` se algum dado obrigatório do array estiver vazio ou inválido.
### Função: `pixCobrancaDinamicoImediataSaqueComValor`
**Descrição:**
Gera uma cobrança PIX dinâmica e imediata para SAQUE com valor predefinido, o usuário pagador não poderá alterar o valor ao efetuar o pagamento.
**Como usar:**
```php
$class = new \Kontrl\PhpKore\Pix($priv, $drone, 'DEV');
$class->pixCobrancaDinamicoImediatoSaqueComValor($dados);
```
**Parâmetros:**
| Nome | Tipo | Obrigatório | Padrão | Descrição |
|----------|-------|-------------|--------|-----------------------------------------------------------------|
| `$dados` | array | Sim | — | Um array com os dados a serem enviados para geração da cobrança |
**Dados:**
| Chave | Tipo | Obrigatório | Descrição | Exemplo |
|----------------------|--------|-------------------------------------------|--------------------------------------------------------------------------------------------------------------|-------------------------|
| `expiracao` | int | Sim | Tempo de expiração em segundos | `3600` |
| `devedor.documento` | string | Não | Documento do pagador | `"09432312054"` |
| `devedor.nome` | string | Não, somente se o documento for informado | Nome do pagador | `"Fulano da Silva"` |
| `valor` | int | Sim | Valor do saque | `10000` (R$100,00) |
| `chave` | string | Sim | Chave Pix de destino | `"12345678911"` |
| `txid` | string | Sim | Identificador da transação | `"098765432111"` |
| `solicitacaoPagador` | string | Não | Mensagem opcional ao pagador | `"Mensagem ao usuário"` |
| `ispb` | string | Sim | ISPB da instituição do prestador de serviço do saque | `"33233"` |
| `modalidadeAgente` | string | Sim | Indica a modalidade do agente a qual se dará a facilitação do serviço. DEVE SER: "agtot", "agtec" ou "agpss" | `"agtot"` |
**Retorno:**
Tipo: `array`
**Notas adicionais:**
- Lança `Exception` se algum dado obrigatório do array estiver vazio ou inválido.
### Função: `pixCobrancaDinamicoImediataSaqueSemValor`
**Descrição:**
Gera uma cobrança PIX dinâmica e imediata para SAQUE sem valor predefinido, o usuário pagador poderá alterar o valor ao efetuar o pagamento.
**Como usar:**
```php
$class = new \Kontrl\PhpKore\Pix($priv, $drone, 'DEV');
$class->pixCobrancaDinamicoImediatoSaqueSemValor($dados);
```
**Parâmetros:**
| Nome | Tipo | Obrigatório | Padrão | Descrição |
|----------|-------|-------------|--------|-----------------------------------------------------------------|
| `$dados` | array | Sim | — | Um array com os dados a serem enviados para geração da cobrança |
**Dados:**
| Chave | Tipo | Obrigatório | Descrição | Exemplo |
|----------------------|--------|-------------------------------------------|--------------------------------------------------------------------------------------------------------------|-------------------------|
| `expiracao` | int | Sim | Tempo de expiração em segundos | `3600` |
| `devedor.documento` | string | Não | Documento do pagador | `"09432312054"` |
| `devedor.nome` | string | Não, somente se o documento for informado | Nome do pagador | `"Fulano da Silva"` |
| `valor` | int | Não | Valor sugerido | `10000` (R$100,00) |
| `chave` | string | Sim | Chave Pix de destino | `"12345678911"` |
| `txid` | string | Sim | Identificador da transação | `"098765432111"` |
| `solicitacaoPagador` | string | Não | Mensagem opcional ao pagador | `"Mensagem ao usuário"` |
| `ispb` | string | Sim | ISPB da instituição do prestador de serviço do saque | `"33233"` |
| `modalidadeAgente` | string | Sim | Indica a modalidade do agente a qual se dará a facilitação do serviço. DEVE SER: "agtot", "agtec" ou "agpss" | `"agtot"` |
**Retorno:**
Tipo: `array`
**Notas adicionais:**
- Lança `Exception` se algum dado obrigatório do array estiver vazio ou inválido.
### Função: `pixCobrancaDinamicoImediataTrocoComValor`
**Descrição:**
Gera uma cobrança PIX dinâmica e imediata para TROCO com valor predefinido, o usuário pagador não poderá alterar o valor ao efetuar o pagamento.
**Como usar:**
```php
$class = new \Kontrl\PhpKore\Pix($priv, $drone, 'DEV');
$class->pixCobrancaDinamicoImediatoTrocoComValor($dados);
```
**Parâmetros:**
| Nome | Tipo | Obrigatório | Padrão | Descrição |
|----------|-------|-------------|--------|-----------------------------------------------------------------|
| `$dados` | array | Sim | — | Um array com os dados a serem enviados para geração da cobrança |
**Dados:**
| Chave | Tipo | Obrigatório | Descrição | Exemplo |
|----------------------|--------|-------------------------------------------|-----------------------------------------------------------------------------------------------------|-------------------------|
| `expiracao` | int | Sim | Tempo de expiração em segundos | `3600` |
| `devedor.documento` | string | Não | Documento do pagador | `"09432312054"` |
| `devedor.nome` | string | Não, somente se o documento for informado | Nome do pagador | `"Fulano da Silva"` |
| `valor` | int | Sim | Valor do troco | `10000` (R$100,00) |
| `chave` | string | Sim | Chave Pix de destino | `"12345678911"` |
| `txid` | string | Sim | Identificador da transação | `"098765432111"` |
| `solicitacaoPagador` | string | Não | Mensagem opcional ao pagador | `"Mensagem ao usuário"` |
| `ispb` | string | Sim | ISPB da instituição do prestador de serviço do troco | `"33233"` |
| `modalidadeAgente` | string | Sim | Indica a modalidade do agente a qual se dará a facilitação do serviço. DEVE SER: "agtot" ou "agtec" | `"agtot"` |
**Retorno:**
Tipo: `array`
**Notas adicionais:**
- Lança `Exception` se algum dado obrigatório do array estiver vazio ou inválido.
### Função: `pixCobrancaDinamicoImediataTrocoSemValor`
**Descrição:**
Gera uma cobrança PIX dinâmica e imediata para TROCO sem valor predefinido, o usuário pagador poderá alterar o valor ao efetuar o pagamento.
**Como usar:**
```php
$class = new \Kontrl\PhpKore\Pix($priv, $drone, 'DEV');
$class->pixCobrancaDinamicoImediatoTrocoSemValor($dados);
```
**Parâmetros:**
| Nome | Tipo | Obrigatório | Padrão | Descrição |
|----------|-------|-------------|--------|-----------------------------------------------------------------|
| `$dados` | array | Sim | — | Um array com os dados a serem enviados para geração da cobrança |
**Dados:**
| Chave | Tipo | Obrigatório | Descrição | Exemplo |
|----------------------|--------|-------------------------------------------|-----------------------------------------------------------------------------------------------------|-------------------------|
| `expiracao` | int | Sim | Tempo de expiração em segundos | `3600` |
| `devedor.documento` | string | Não | Documento do pagador | `"09432312054"` |
| `devedor.nome` | string | Não, somente se o documento for informado | Nome do pagador | `"Fulano da Silva"` |
| `valor` | int | Não | Valor sugerido | `10000` (R$100,00) |
| `chave` | string | Sim | Chave Pix de destino | `"12345678911"` |
| `txid` | string | Sim | Identificador da transação | `"098765432111"` |
| `solicitacaoPagador` | string | Não | Mensagem opcional ao pagador | `"Mensagem ao usuário"` |
| `ispb` | string | Sim | ISPB da instituição do prestador de serviço do troco | `"33233"` |
| `modalidadeAgente` | string | Sim | Indica a modalidade do agente a qual se dará a facilitação do serviço. DEVE SER: "agtot" ou "agtec" | `"agtot"` |
**Retorno:**
Tipo: `array`
**Notas adicionais:**
- Lança `Exception` se algum dado obrigatório do array estiver vazio ou inválido.
### Função: `pixCobrancaEstatico`
**Descrição:**
Gera uma cobrança PIX estática com ou sem valor predefinido.
**Como usar:**
```php
$class = new \Kontrl\PhpKore\Pix($priv, $drone, 'DEV');
$class->pixCobrancaEstatico($dados);
```
**Parâmetros:**
| Nome | Tipo | Obrigatório | Padrão | Descrição |
|----------|-------|-------------|--------|-----------------------------------------------------------------|
| `$dados` | array | Sim | — | Um array com os dados a serem enviados para geração da cobrança |
**Dados:**
| Chave | Tipo | Obrigatório | Descrição | Exemplo |
|----------------------|--------|-------------------------------------------|--------------------------------|-------------------------|
| `valor` | int | Não | Valor sugerido | `10000` (R$100,00) |
| `chave` | string | Sim | Chave Pix de destino | `"12345678911"` |
| `txid` | string | Sim | Identificador da transação | `"098765432111"` |
| `solicitacaoPagador` | string | Não | Mensagem opcional ao pagador | `"Mensagem ao usuário"` |
**Retorno:**
Tipo: `array`
**Notas adicionais:**
- Lança `Exception` se algum dado obrigatório do array estiver vazio ou inválido.

View file

@ -16,5 +16,7 @@
"email": "me@bacarin.dev"
}
],
"require": {}
"require": {
"phpseclib/phpseclib": "~3.0"
}
}

View file

@ -2,27 +2,31 @@
namespace Kontrl\PhpKore;
use phpseclib3\Crypt\PublicKeyLoader;
class Kore
{
private $url = 'https://httpbin.org';
private $token;
public function __construct(){
$this->token = $this->auth();
public $url = 'https://stage.kore.kontrl.tech';
public $privateKey;
public $drone;
public function __construct($privateKey, $drone, $environment = 'DEV') {
$this->privateKey = $privateKey;
$this->drone = $drone;
if ($environment == 'PROD'){
$this->url = 'https://kore.kontrl.tech';
}
}
public function auth(){
return '';
}
public function testRequest(){
return [
'get' => curlRequest($this->url.'/get', 'GET')['status'],
'post' => curlRequest($this->url.'/post', 'POST', [], [], ['test' => 'test'])['status'],
'patch' => curlRequest($this->url.'/patch', 'PATCH', [], [], ['test' => 'test'])['status'],
'put' => curlRequest($this->url.'/put', 'PUT', [], [], ['test' => 'test'])['status'],
'delete' => curlRequest($this->url.'/delete', 'DELETE')['status']
];
public function signBody($body, $password = false)
{
$privateKey = PublicKeyLoader::loadPrivateKey(base64_decode($this->privateKey), $password);
$sig = $privateKey->sign(json_encode($body));
return base64_encode($sig);
}
public function verifySignature($signature, $message, $key)
{
$publicKey = PublicKeyLoader::loadPublicKey($key);
return $publicKey->verify(json_encode($message), $signature);
}
}

281
src/Pix.php Normal file
View file

@ -0,0 +1,281 @@
<?php
namespace Kontrl\PhpKore;
include_once(__DIR__ . '/rules.php');
class Pix extends Kore
{
public function pixCobrancaDinamicoImediataComValor($payload)
{
pixCobrancaImediataComValorRules($payload);
$korePayload = [
'calendario' => [
'expiracao' => $payload['expiracao'] ?? 86400,
],
'valor' => [
'original' => $payload['valor'],
'modalidadeAlteracao' => 0,
],
'chave' => $payload['chave'],
'txid' => $payload['txid'],
'solicitacaoPagador' => $payload['solicitacaoPagador'] ?? null
];
if (isset($payload['devedor'])) {
if (strlen($payload['devedor']['documento']) > 11) {
$korePayload['devedor']['cnpj'] = $payload['devedor']['documento'];
} else {
$korePayload['devedor']['cpf'] = $payload['devedor']['documento'];
}
$korePayload['devedor']['nome'] = $payload['devedor'];
}
return curlRequest(
$this->url . '/post',
'POST',
[],
[
'x-kore-drone-uid: drone:' . $this->drone,
'x-kore-drone-sign: ' . $this->signBody($korePayload)
],
$payload
);
}
public function pixCobrancaDinamicoImediataSemValor($payload)
{
pixCobrancaImediataSemValorRules($payload);
$korePayload = [
'calendario' => [
'expiracao' => $payload['expiracao'] ?? 86400,
],
'valor' => [
'original' => $payload['valor'] ?? 0,
'modalidadeAlteracao' => 1,
],
'chave' => $payload['chave'],
'txid' => $payload['txid'],
'solicitacaoPagador' => $payload['solicitacaoPagador'] ?? null
];
if (isset($payload['devedor'])) {
if (strlen($payload['devedor']['documento']) > 11) {
$korePayload['devedor']['cnpj'] = $payload['devedor']['documento'];
} else {
$korePayload['devedor']['cpf'] = $payload['devedor']['documento'];
}
$korePayload['devedor']['nome'] = $payload['devedor'];
}
return curlRequest(
$this->url . '/post',
'POST',
[],
[
'x-kore-drone-uid: drone:' . $this->drone,
'x-kore-drone-sign: ' . $this->signBody($korePayload)
],
$payload
);
}
public function pixCobrancaDinamicoImediatoSaqueSemValor($payload)
{
pixCobrancaImediataSaqueSemValorRules($payload);
$korePayload = [
'calendario' => [
'expiracao' => $payload['expiracao'] ?? 86400,
],
'valor' => [
'original' => 0,
'retirada' => [
'saque' => [
'valor' => $payload['valor'] ?? 0,
'modalidadeAlteracao' => 1,
'prestadorDoServicoDeSaque' => $payload['ispb'],
'modalidadeAgente' => $payload['modalidadeAgente']
]
]
],
'chave' => $payload['chave'],
'txid' => $payload['txid'],
'solicitacaoPagador' => $payload['solicitacaoPagador'] ?? null
];
if (isset($payload['devedor'])) {
if (strlen($payload['devedor']['documento']) > 11) {
$korePayload['devedor']['cnpj'] = $payload['devedor']['documento'];
} else {
$korePayload['devedor']['cpf'] = $payload['devedor']['documento'];
}
$korePayload['devedor']['nome'] = $payload['devedor'];
}
return curlRequest(
$this->url . '/post',
'POST',
[],
[
'x-kore-drone-uid: drone:' . $this->drone,
'x-kore-drone-sign: ' . $this->signBody($korePayload)
],
$payload
);
}
public function pixCobrancaDinamicoImediatoSaqueComValor($payload)
{
pixCobrancaImediataSaqueComValorRules($payload);
$korePayload = [
'calendario' => [
'expiracao' => $payload['expiracao'] ?? 86400,
],
'valor' => [
'original' => 0,
'retirada' => [
'saque' => [
'valor' => $payload['valor'],
'modalidadeAlteracao' => 0,
'prestadorDoServicoDeSaque' => $payload['ispb'],
'modalidadeAgente' => $payload['modalidadeAgente']
]
]
],
'chave' => $payload['chave'],
'txid' => $payload['txid'],
'solicitacaoPagador' => $payload['solicitacaoPagador'] ?? null
];
if (isset($payload['devedor'])) {
if (strlen($payload['devedor']['documento']) > 11) {
$korePayload['devedor']['cnpj'] = $payload['devedor']['documento'];
} else {
$korePayload['devedor']['cpf'] = $payload['devedor']['documento'];
}
$korePayload['devedor']['nome'] = $payload['devedor'];
}
return curlRequest(
$this->url . '/post',
'POST',
[],
[
'x-kore-drone-uid: drone:' . $this->drone,
'x-kore-drone-sign: ' . $this->signBody($korePayload)
],
$payload
);
}
public function pixCobrancaDinamicoImediatoTrocoSemValor($payload)
{
pixCobrancaImediataTrocoSemValorRules($payload);
$korePayload = [
'calendario' => [
'expiracao' => $payload['expiracao'] ?? 86400,
],
'valor' => [
'original' => 0,
'retirada' => [
'troco' => [
'valor' => $payload['valor'] ?? 0,
'modalidadeAlteracao' => 1,
'prestadorDoServicoDeSaque' => $payload['ispb'],
'modalidadeAgente' => $payload['modalidadeAgente']
]
]
],
'chave' => $payload['chave'],
'txid' => $payload['txid'],
'solicitacaoPagador' => $payload['solicitacaoPagador'] ?? null
];
if (isset($payload['devedor'])) {
if (strlen($payload['devedor']['documento']) > 11) {
$korePayload['devedor']['cnpj'] = $payload['devedor']['documento'];
} else {
$korePayload['devedor']['cpf'] = $payload['devedor']['documento'];
}
$korePayload['devedor']['nome'] = $payload['devedor'];
}
return curlRequest(
$this->url . '/post',
'POST',
[],
[
'x-kore-drone-uid: drone:' . $this->drone,
'x-kore-drone-sign: ' . $this->signBody($korePayload)
],
$payload
);
}
public function pixCobrancaDinamicoImediatoTrocoComValor($payload)
{
pixCobrancaImediataTrocoComValorRules($payload);
$korePayload = [
'calendario' => [
'expiracao' => $payload['expiracao'] ?? 86400,
],
'valor' => [
'original' => 0,
'retirada' => [
'troco' => [
'valor' => $payload['valor'],
'modalidadeAlteracao' => 0,
'prestadorDoServicoDeSaque' => $payload['ispb'],
'modalidadeAgente' => $payload['modalidadeAgente']
]
]
],
'chave' => $payload['chave'],
'txid' => $payload['txid'],
'solicitacaoPagador' => $payload['solicitacaoPagador'] ?? null
];
if (isset($payload['devedor'])) {
if (strlen($payload['devedor']['documento']) > 11) {
$korePayload['devedor']['cnpj'] = $payload['devedor']['documento'];
} else {
$korePayload['devedor']['cpf'] = $payload['devedor']['documento'];
}
$korePayload['devedor']['nome'] = $payload['devedor'];
}
return curlRequest(
$this->url . '/post',
'POST',
[],
[
'x-kore-drone-uid: drone:' . $this->drone,
'x-kore-drone-sign: ' . $this->signBody($korePayload)
],
$payload
);
}
public function pixCobrancaEstatico($payload)
{
pixCobrancaEstaticoRules($payload);
$korePayload = [
'valor' => $payload['valor'] ?? 0,
'chave' => $payload['chave'],
'txid' => $payload['txid'] ?? null,
'solicitacaoPagador' => $payload['solicitacaoPagador'] ?? null
];
return curlRequest(
$this->url . '/post',
'POST',
[],
[
'x-kore-drone-uid: drone:' . $this->drone,
'x-kore-drone-sign: ' . $this->signBody($korePayload)
],
$payload
);
}
}

View file

@ -2,18 +2,18 @@
if (!function_exists('curlRequest')) {
function curlRequest(
string $url,
string $method = 'GET',
array $queryParams = [],
array $headers = [],
array|string|null $body = null
$url,
$method = 'GET',
$queryParams = [],
$headers = [],
$body = null
): array {
$curl = curl_init();
if (!empty($queryParams)) {
$url .= (strpos($url, '?') === false ? '?' : '&') . http_build_query($queryParams);
}
$options = [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
@ -29,7 +29,7 @@ if (!function_exists('curlRequest')) {
}
$options[CURLOPT_POSTFIELDS] = $body;
}
if (!empty($headers)) {
$options[CURLOPT_HTTPHEADER] = $headers;
}

154
src/rules.php Normal file
View file

@ -0,0 +1,154 @@
<?php
require_once(__DIR__ . '/validator.php');
function pixCobrancaImediataComValorRules(array $data)
{
$rules = [
'expiracao' => 'sometimes|integer',
'devedor' => 'sometimes|array',
'devedor.documento' => 'sometimes|string|min:11|max:18',
'devedor.nome' => 'sometimes|required_with:devedor.documento|string|max:100',
'valor' => 'required|integer|min:1',
'chave' => 'required|string',
'txid' => 'required|string|max:100',
'solicitacaoPagador' => 'string|max:140'
];
$validate = validate($data, $rules);
if (!$validate['valid']) {
throw new Exception(json_encode(array_slice($validate['errors'], 0, 1)), 500);
} else {
return true;
}
}
function pixCobrancaImediataSemValorRules(array $data)
{
$rules = [
'expiracao' => 'sometimes|integer',
'devedor' => 'sometimes|array',
'devedor.documento' => 'sometimes|string|min:11|max:18',
'devedor.nome' => 'sometimes|required_with:devedor.documento|string|max:100',
'valor' => 'sometimes|integer',
'chave' => 'required|string',
'txid' => 'required|string|max:100',
'solicitacaoPagador' => 'string|max:140'
];
$validate = validate($data, $rules);
if (!$validate['valid']) {
throw new Exception(json_encode(array_slice($validate['errors'], 0, 1)), 500);
} else {
return true;
}
}
function pixCobrancaImediataSaqueSemValorRules(array $data)
{
$rules = [
'expiracao' => 'sometimes|integer',
'devedor' => 'sometimes|array',
'devedor.documento' => 'sometimes|string|min:11|max:18',
'devedor.nome' => 'sometimes|required_with:devedor.documento|string|max:100',
'valor' => 'sometimes|integer',
'chave' => 'required|string',
'txid' => 'required|string|max:100',
'solicitacaoPagador' => 'string|max:140',
'ispb' => 'required|string',
'modalidadeAgente' => 'required|string|in:agtec,agtot,agpss'
];
$validate = validate($data, $rules);
if (!$validate['valid']) {
throw new Exception(json_encode(array_slice($validate['errors'], 0, 1)), 500);
} else {
return true;
}
}
function pixCobrancaImediataSaqueComValorRules(array $data)
{
$rules = [
'expiracao' => 'sometimes|integer',
'devedor' => 'sometimes|array',
'devedor.documento' => 'sometimes|string|min:11|max:18',
'devedor.nome' => 'sometimes|required_with:devedor.documento|string|max:100',
'valor' => 'required|integer',
'chave' => 'required|string',
'txid' => 'required|string|max:100',
'solicitacaoPagador' => 'string|max:140',
'ispb' => 'required|string',
'modalidadeAgente' => 'required|string|in:agtec,agtot,agpss'
];
$validate = validate($data, $rules);
if (!$validate['valid']) {
throw new Exception(json_encode(array_slice($validate['errors'], 0, 1)), 500);
} else {
return true;
}
}
function pixCobrancaImediataTrocoSemValorRules(array $data)
{
$rules = [
'expiracao' => 'sometimes|integer',
'devedor' => 'sometimes|array',
'devedor.documento' => 'sometimes|string|min:11|max:18',
'devedor.nome' => 'sometimes|required_with:devedor.documento|string|max:100',
'valor' => 'sometimes|integer',
'chave' => 'required|string',
'txid' => 'required|string|max:100',
'solicitacaoPagador' => 'string|max:140',
'ispb' => 'required|string',
'modalidadeAgente' => 'required|string|in:agtec,agtot'
];
$validate = validate($data, $rules);
if (!$validate['valid']) {
throw new Exception(json_encode(array_slice($validate['errors'], 0, 1)), 500);
} else {
return true;
}
}
function pixCobrancaImediataTrocoComValorRules(array $data)
{
$rules = [
'expiracao' => 'sometimes|integer',
'devedor' => 'sometimes|array',
'devedor.documento' => 'sometimes|string|min:11|max:18',
'devedor.nome' => 'sometimes|required_with:devedor.documento|string|max:100',
'valor' => 'sometimes|integer',
'chave' => 'required|string',
'txid' => 'required|string|max:100',
'solicitacaoPagador' => 'string|max:140',
'ispb' => 'required|string',
'modalidadeAgente' => 'required|string|in:agtec,agtot'
];
$validate = validate($data, $rules);
if (!$validate['valid']) {
throw new Exception(json_encode(array_slice($validate['errors'], 0, 1)), 500);
} else {
return true;
}
}
function pixCobrancaEstaticoRules(array $data)
{
$rules = [
'valor' => 'sometimes|integer',
'chave' => 'required|string',
'txid' => 'sometimes|string|max:100',
'solicitacaoPagador' => 'sometimes|string|max:140',
];
$validate = validate($data, $rules);
if (!$validate['valid']) {
throw new Exception(json_encode(array_slice($validate['errors'], 0, 1)), 500);
} else {
return true;
}
}

176
src/validator.php Normal file
View file

@ -0,0 +1,176 @@
<?php
function fieldExistsInData($data, $key)
{
$keys = explode('.', $key);
foreach ($keys as $k) {
if (is_array($data) && array_key_exists($k, $data)) {
$data = $data[$k];
} else {
return false;
}
}
return true;
}
function getDataValue($data, $key)
{
$keys = explode('.', $key);
foreach ($keys as $k) {
if (is_array($data) && array_key_exists($k, $data)) {
$data = $data[$k];
} else {
return null;
}
}
return $data;
}
function validate($data, $rules)
{
$errors = [];
foreach ($rules as $field => $ruleString) {
$value = getDataValue($data, $field);
$ruleList = explode('|', $ruleString);
$hasSometimes = in_array('sometimes', $ruleList, true);
if ($hasSometimes && !fieldExistsInData($data, $field)) {
continue;
}
foreach ($ruleList as $ruleItem) {
if ($ruleItem === 'sometimes') {
continue; // already handled
}
$param = null;
if (strpos($ruleItem, ':') !== false) {
$exploded = explode(':', $ruleItem, 2);
$rule = $exploded[0];
$param = isset($exploded[1]) ? $exploded[1] : null;
} else {
$rule = $ruleItem;
}
$validator = 'validate_' . $rule;
if (function_exists($validator)) {
$result = $validator($field, $value, $param, $data);
if ($result !== true) {
$errors[$field][] = $result;
}
} else {
$errors[$field][] = "Rule '$rule' is not supported.";
}
}
}
return ['valid' => !empty($errors) ? false : true, 'errors' => $errors];
}
function validate_array($field, $value, $param = null, $data = [])
{
if (!is_array($value)) {
return "The field '$field' must be an array.";
}
return true;
}
function validate_in($field, $value, $param, $data = [])
{
if ($param === null) {
return "The rule 'in' requires a list of accepted values.";
}
$accepted = explode(',', $param);
if (!in_array((string) $value, $accepted, true)) {
return "The field '$field' must be one of: " . implode(', ', $accepted) . ".";
}
return true;
}
function validate_integer($field, $value, $param = null, $data = [])
{
if (!is_int($value)) {
return "The field '$field' must be an integer.";
}
return true;
}
function validate_max($field, $value, $param, $data = [])
{
if (is_string($value) && strlen($value) > $param) {
return "The field '$field' must have at most $param characters.";
}
if (is_integer($value) && $value > $param) {
return "The value of '$field' must be at most $param.";
}
return true;
}
function validate_min($field, $value, $param, $data = [])
{
if (is_string($value) && strlen($value) < $param) {
return "The field '$field' must have at least $param characters.";
}
if (is_numeric($value) && $value < $param) {
return "The value of '$field' must be at least $param.";
}
return true;
}
function validate_prohibited_with($field, $value, $param, $data = [])
{
$otherFields = explode(',', $param);
foreach ($otherFields as $other) {
$other = trim($other);
if (!empty($data[$other])) {
if (!empty($value)) {
return "The field '$field' is not allowed when '$other' is present.";
}
}
}
return true;
}
function validate_required($field, $value, $param = null, $data = [])
{
if ($value === null || $value === '') {
return "The field '$field' is required.";
}
return true;
}
function validate_required_with($field, $value, $param, $data = [])
{
$relatedFields = explode(',', $param);
foreach ($relatedFields as $related) {
$related = trim($related);
if (isset($data[$related]) && $data[$related] !== '') {
if ($value === null || $value === '') {
return "The field '$field' is required when '$related' is present.";
}
}
}
return true;
}
function validate_string($field, $value, $param = null, $data = [])
{
if (!is_string($value)) {
return "The field '$field' must be a string.";
}
return true;
}

22
vendor/autoload.php vendored
View file

@ -1,22 +0,0 @@
<?php
// autoload.php @generated by Composer
if (PHP_VERSION_ID < 50600) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
throw new RuntimeException($err);
}
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit60f22886a6c2e74ff0ac05bdf2882e7a::getLoader();

View file

@ -1,579 +0,0 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see https://www.php-fig.org/psr/psr-0/
* @see https://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
/** @var \Closure(string):void */
private static $includeFile;
/** @var string|null */
private $vendorDir;
// PSR-4
/**
* @var array<string, array<string, int>>
*/
private $prefixLengthsPsr4 = array();
/**
* @var array<string, list<string>>
*/
private $prefixDirsPsr4 = array();
/**
* @var list<string>
*/
private $fallbackDirsPsr4 = array();
// PSR-0
/**
* List of PSR-0 prefixes
*
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
*
* @var array<string, array<string, list<string>>>
*/
private $prefixesPsr0 = array();
/**
* @var list<string>
*/
private $fallbackDirsPsr0 = array();
/** @var bool */
private $useIncludePath = false;
/**
* @var array<string, string>
*/
private $classMap = array();
/** @var bool */
private $classMapAuthoritative = false;
/**
* @var array<string, bool>
*/
private $missingClasses = array();
/** @var string|null */
private $apcuPrefix;
/**
* @var array<string, self>
*/
private static $registeredLoaders = array();
/**
* @param string|null $vendorDir
*/
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
self::initializeIncludeClosure();
}
/**
* @return array<string, list<string>>
*/
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}
return array();
}
/**
* @return array<string, list<string>>
*/
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
/**
* @return list<string>
*/
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
/**
* @return list<string>
*/
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
/**
* @return array<string, string> Array of classname => path
*/
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array<string, string> $classMap Class to filename map
*
* @return void
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param list<string>|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*
* @return void
*/
public function add($prefix, $paths, $prepend = false)
{
$paths = (array) $paths;
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
$paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
$paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
$paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param list<string>|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
$paths = (array) $paths;
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
$paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
$paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
$paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param list<string>|string $paths The PSR-0 base directories
*
* @return void
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param list<string>|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*
* @return void
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*
* @return void
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*
* @return void
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}
/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*
* @return void
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
if (null === $this->vendorDir) {
return;
}
if ($prepend) {
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
} else {
unset(self::$registeredLoaders[$this->vendorDir]);
self::$registeredLoaders[$this->vendorDir] = $this;
}
}
/**
* Unregisters this instance as an autoloader.
*
* @return void
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
if (null !== $this->vendorDir) {
unset(self::$registeredLoaders[$this->vendorDir]);
}
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return true|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
$includeFile = self::$includeFile;
$includeFile($file);
return true;
}
return null;
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}
return $file;
}
/**
* Returns the currently registered loaders keyed by their corresponding vendor directories.
*
* @return array<string, self>
*/
public static function getRegisteredLoaders()
{
return self::$registeredLoaders;
}
/**
* @param string $class
* @param string $ext
* @return string|false
*/
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
return false;
}
/**
* @return void
*/
private static function initializeIncludeClosure()
{
if (self::$includeFile !== null) {
return;
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*
* @param string $file
* @return void
*/
self::$includeFile = \Closure::bind(static function($file) {
include $file;
}, null, null);
}
}

View file

@ -1,21 +0,0 @@
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View file

@ -1,10 +0,0 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
);

View file

@ -1,10 +0,0 @@
<?php
// autoload_files.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'ad53562c95430a8cfe99d24812652dc1' => $baseDir . '/src/helpers.php',
);

View file

@ -1,9 +0,0 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
);

View file

@ -1,10 +0,0 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'Kontrl\\PhpKore\\' => array($baseDir . '/src'),
);

View file

@ -1,48 +0,0 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit60f22886a6c2e74ff0ac05bdf2882e7a
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit60f22886a6c2e74ff0ac05bdf2882e7a', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit60f22886a6c2e74ff0ac05bdf2882e7a', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit60f22886a6c2e74ff0ac05bdf2882e7a::getInitializer($loader));
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit60f22886a6c2e74ff0ac05bdf2882e7a::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
require $file;
}
}, null, null);
foreach ($filesToLoad as $fileIdentifier => $file) {
$requireFile($fileIdentifier, $file);
}
return $loader;
}
}

View file

@ -1,40 +0,0 @@
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInit60f22886a6c2e74ff0ac05bdf2882e7a
{
public static $files = array (
'ad53562c95430a8cfe99d24812652dc1' => __DIR__ . '/../..' . '/src/helpers.php',
);
public static $prefixLengthsPsr4 = array (
'K' =>
array (
'Kontrl\\PhpKore\\' => 15,
),
);
public static $prefixDirsPsr4 = array (
'Kontrl\\PhpKore\\' =>
array (
0 => __DIR__ . '/../..' . '/src',
),
);
public static $classMap = array (
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit60f22886a6c2e74ff0ac05bdf2882e7a::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit60f22886a6c2e74ff0ac05bdf2882e7a::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit60f22886a6c2e74ff0ac05bdf2882e7a::$classMap;
}, null, ClassLoader::class);
}
}