1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Exemplo de uso |
4
|
|
|
* |
5
|
|
|
* Criação do arquivo de cadastro |
6
|
|
|
* |
7
|
|
|
* @author Thiago Paes <[email protected]> |
8
|
|
|
*/ |
9
|
|
|
use MrPrompt\Centercob\Factory; |
10
|
|
|
use MrPrompt\Centercob\Shipment\File; |
11
|
|
|
use MrPrompt\ShipmentCommon\Base\Cart; |
12
|
|
|
use MrPrompt\ShipmentCommon\Base\Sequence; |
13
|
|
|
|
14
|
|
|
require __DIR__ . '/bootstrap.php'; |
15
|
|
|
|
16
|
|
|
/* @var $today \DateTime */ |
17
|
|
|
$today = new DateTime(); |
18
|
|
|
|
19
|
|
|
/* @var $cart \MrPrompt\ShipmentCommon\Base\Cart */ |
20
|
|
|
$cart = new Cart(); |
21
|
|
|
|
22
|
|
|
/* @var $lista array */ |
23
|
|
|
$lista = require __DIR__ . '/cart.php'; |
24
|
|
|
|
25
|
|
|
foreach ($lista as $linha) { |
26
|
|
|
if (in_array($linha['cobranca'], [\MrPrompt\ShipmentCommon\Base\Charge::BILLET, \MrPrompt\ShipmentCommon\Base\Charge::PAYMENT_SLIP])) { |
27
|
|
|
continue; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/* @var $item \MrPrompt\Centercob\Shipment\Partial\Detail */ |
31
|
|
|
$item = Factory::createDetailFromArray($linha); |
32
|
|
|
|
33
|
|
|
echo 'Tipo: ', $item->getCharge()->getCharging(), PHP_EOL; |
34
|
|
|
echo 'Comprador: ', $item->getPurchaser()->getName(), PHP_EOL; |
35
|
|
|
echo 'Parcelas: ', PHP_EOL; |
36
|
|
|
|
37
|
|
|
foreach ($item->getParcels() as $parcel) { |
38
|
|
|
echo ' # ', ($parcel->getKey() + 1), PHP_EOL; |
39
|
|
|
echo ' R$ ', number_format($parcel->getPrice(), 2, ',', '.'), PHP_EOL; |
40
|
|
|
echo ' Qtd ', $parcel->getQuantity(), PHP_EOL; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
// echo 'Status: ', $item->getCharge()->getOccurrence()->getDescription(), PHP_EOL; |
44
|
|
|
echo PHP_EOL, PHP_EOL; |
45
|
|
|
|
46
|
|
|
$cart->addItem($item); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
try { |
50
|
|
|
/* @var $sequence \MrPrompt\ShipmentCommon\Base\Sequence */ |
51
|
|
|
$sequence = new Sequence(8); |
52
|
|
|
|
53
|
|
|
/* @var $customer \MrPrompt\ShipmentCommon\Base\Customer */ |
54
|
|
|
$customer = Factory::createCustomerFromArray(array_shift($lista)); |
55
|
|
|
|
56
|
|
|
/* @var $exporter \MrPrompt\Centercob\Shipment\File */ |
57
|
|
|
$exporter = new File($customer, $sequence, $today, __DIR__ . DIRECTORY_SEPARATOR . 'enviados', File::TEMPLATE_GENERATED); |
|
|
|
|
58
|
|
|
|
59
|
|
|
$exporter->setCart($cart); |
60
|
|
|
|
61
|
|
|
$result = $exporter->save(); |
62
|
|
|
|
63
|
|
|
echo sprintf('Arquivo %s gerado com sucesso no diretório %s', basename($result), dirname($result)), PHP_EOL; |
64
|
|
|
} catch (\InvalidArgumentException $ex) { |
65
|
|
|
echo sprintf('Erro: %s in file: %s - line: %s', $ex->getMessage(), $ex->getFile(), $ex->getLine()), PHP_EOL; |
66
|
|
|
} |
67
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.