mathieutu /
laravel-json-syncer
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace MathieuTu\JsonSyncer\Traits; |
||||
| 4 | |||||
| 5 | use MathieuTu\JsonSyncer\Helpers\JsonImporter as ImporterHelper; |
||||
| 6 | use MathieuTu\JsonSyncer\Helpers\RelationsInModelFinder; |
||||
| 7 | |||||
| 8 | trait JsonImporter |
||||
| 9 | { |
||||
| 10 | protected $jsonImportableAttributes; |
||||
| 11 | protected $jsonImportableRelations; |
||||
| 12 | |||||
| 13 | 15 | public static function importFromJson($objects) |
|||
| 14 | { |
||||
| 15 | 15 | ImporterHelper::importFromJson(new static, $objects); |
|||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 16 | 14 | } |
|||
| 17 | |||||
| 18 | 15 | public function getJsonImportableAttributes(): array |
|||
| 19 | { |
||||
| 20 | 15 | return $this->jsonImportableAttributes |
|||
| 21 | 14 | ?? $this->jsonExportableAttributes |
|||
|
0 ignored issues
–
show
|
|||||
| 22 | 15 | ?? $this->getFillable(); |
|||
|
0 ignored issues
–
show
It seems like
getFillable() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 23 | } |
||||
| 24 | |||||
| 25 | 14 | public function getJsonImportableRelations(): array |
|||
| 26 | { |
||||
| 27 | 14 | return $this->jsonImportableRelations |
|||
| 28 | 14 | ?? $this->jsonExportableRelations |
|||
|
0 ignored issues
–
show
|
|||||
| 29 | 14 | ?? RelationsInModelFinder::hasOneOrMany($this); |
|||
|
0 ignored issues
–
show
$this of type MathieuTu\JsonSyncer\Traits\JsonImporter is incompatible with the type Illuminate\Database\Eloquent\Model expected by parameter $model of MathieuTu\JsonSyncer\Hel...lFinder::hasOneOrMany().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 30 | } |
||||
| 31 | |||||
| 32 | 1 | public function isImporting(): bool |
|||
| 33 | { |
||||
| 34 | 1 | return collect(debug_backtrace())->contains('class', ImporterHelper::class); |
|||
| 35 | } |
||||
| 36 | } |
||||
| 37 |