| Total Complexity | 8 |
| Total Lines | 81 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class Transaction |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Current transaction's database. |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | protected $db; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Transaction result. |
||
| 20 | * @var array |
||
| 21 | */ |
||
| 22 | protected $results; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * SQL Query error. |
||
| 26 | * @var mixed |
||
| 27 | */ |
||
| 28 | protected $error; |
||
| 29 | |||
| 30 | |||
| 31 | /** |
||
| 32 | * Transacion |
||
| 33 | * Responsible to holds transaction behave. |
||
| 34 | * @param mixed $closure |
||
| 35 | */ |
||
| 36 | public function __construct($closure = null) |
||
| 37 | { |
||
| 38 | if (is_callable($closure)) { |
||
| 39 | $connection = $this->getConnection(); |
||
| 40 | try { |
||
| 41 | $connection->beginTransaction(); |
||
| 42 | $this->results = $closure($connection); |
||
| 43 | if ($this->results === false) { |
||
| 44 | $connection->rollbackTransaction(); |
||
| 45 | } else { |
||
| 46 | $connection->commitTransaction(); |
||
| 47 | } |
||
| 48 | } catch (\Exception $e) { |
||
| 49 | $connection->rollbackTransaction(); |
||
| 50 | $this->error = $e; |
||
| 51 | } |
||
| 52 | } |
||
| 53 | return $this; |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Gets current connection. |
||
| 58 | * @param string $name |
||
| 59 | * @return \Connection |
||
|
|
|||
| 60 | */ |
||
| 61 | public function getConnection($name = null) |
||
| 62 | { |
||
| 63 | return ConnectionManager::initialize()->current(); |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Gets query results. |
||
| 68 | * @return array |
||
| 69 | */ |
||
| 70 | public function getResults() |
||
| 71 | { |
||
| 72 | return $this->results; |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Gets transacion's error. |
||
| 77 | * @return mixed |
||
| 78 | */ |
||
| 79 | public function getError() |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Checks if transacion has error. |
||
| 86 | * @return boolean |
||
| 87 | */ |
||
| 88 | public function hasError() |
||
| 91 | } |
||
| 92 | } |
||
| 93 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths