Conditions | 4 |
Paths | 6 |
Total Lines | 23 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 5.3398 |
Changes | 0 |
1 | <?php |
||
47 | 1 | public function __construct(string $str) |
|
48 | { |
||
49 | 1 | $this->opis = strip_tags($str); |
|
50 | try { |
||
51 | 1 | $aElem = HtmlDomParser::str_get_html($str)->getElementByTagName('a'); |
|
52 | 1 | if ($aElem) { |
|
53 | 1 | $sHref = $aElem->getAttribute('href'); |
|
54 | 1 | $id = (int)str_replace('/dane/krs_podmioty/', '', $sHref); |
|
55 | 1 | if ($id > 0) { |
|
56 | 1 | $this->podmiot_id = $id; |
|
57 | } else { |
||
58 | throw new \RuntimeException('KRS id not found in href'); |
||
59 | } |
||
60 | } |
||
61 | } catch (\Exception $e) { |
||
62 | $this->podmiot_id = null; |
||
63 | Api::getInstance() |
||
64 | ->getClient() |
||
65 | ->getLogger() |
||
66 | ->warning(sprintf('Related entity [%s] Error: %s', $str, $e->getMessage())) |
||
67 | ; |
||
68 | } |
||
69 | 1 | } |
|
70 | } |
||
71 |