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