| Conditions | 7 |
| Paths | 4 |
| Total Lines | 25 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | public static function addData($id, MediaInfoContainer $xmlArray): void |
||
| 16 | { |
||
| 17 | $mediainfoArray = $xmlArray->getGeneral(); |
||
| 18 | if (! $mediainfoArray) { |
||
| 19 | return; |
||
| 20 | } |
||
| 21 | |||
| 22 | // Check if we have the same release in the database |
||
| 23 | if (self::where('releases_id', $id)->exists()) { |
||
| 24 | return; |
||
| 25 | } |
||
| 26 | |||
| 27 | $mediaUniqueId = $mediainfoArray->get('unique_id'); |
||
| 28 | // If unique_id is not present or is 0 or 0x0, we don't want to store it, as it's not unique |
||
| 29 | if ($mediaUniqueId === null || $mediaUniqueId === '0' || $mediaUniqueId === '0x0' || $mediaUniqueId === 0) { |
||
| 30 | $mediaUniqueId = null; |
||
| 31 | } |
||
| 32 | |||
| 33 | self::insertOrIgnore([ |
||
| 34 | 'releases_id' => $id, |
||
| 35 | 'movie_name' => $mediainfoArray->get('movie_name') ?? null, |
||
| 36 | 'file_name' => $mediainfoArray->get('file_name') ?? null, |
||
| 37 | 'unique_id' => $mediainfoArray->get('unique_id') ?? null, |
||
| 38 | 'created_at' => now(), |
||
| 39 | 'updated_at' => now(), |
||
| 40 | ]); |
||
| 43 |