| Conditions | 2 |
| Paths | 2 |
| Total Lines | 19 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | public static function forAction(ActionInterface $action, Throwable $previousException): self |
||
| 20 | { |
||
| 21 | if ($action->getId() !== null) { |
||
|
|
|||
| 22 | $message = sprintf('Failed to charge action %s: %s', $action->getId(), $previousException->getMessage()); |
||
| 23 | } else { |
||
| 24 | $message = sprintf( |
||
| 25 | 'Failed to charge action (type: %s, target: %s, quantity: %s %s, customer: %s, time: %s): %s', |
||
| 26 | $action->getType()->getName(), $action->getTarget()->getUniqueId(), |
||
| 27 | $action->getQuantity()->getQuantity(), $action->getQuantity()->getUnit()->getName(), |
||
| 28 | $action->getCustomer()->getLogin(), |
||
| 29 | $action->getTime()->format(DATE_ATOM), |
||
| 30 | $previousException->getMessage() |
||
| 31 | ); |
||
| 32 | } |
||
| 33 | |||
| 34 | $self = new self($message, 0, $previousException); |
||
| 35 | $self->action = $action; |
||
| 36 | |||
| 37 | return $self; |
||
| 38 | } |
||
| 45 |