Completed
Push — main ( cffc6f...c8373b )
by Tan
29s queued 16s
created

MetaBoxController::getMetaBoxBySlugModel()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 2
nc 2
nop 3
1
<?php
2
3
namespace CSlant\Blog\Api\Http\Controllers;
4
5
use CSlant\Blog\Api\Services\MetaBoxService;
6
use CSlant\Blog\Api\Services\SlugService;
7
use CSlant\Blog\Core\Constants\AppConstant;
0 ignored issues
show
Bug introduced by
The type CSlant\Blog\Core\Constants\AppConstant was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Illuminate\Database\Eloquent\Model;
9
10
class MetaBoxController
11
{
12
    protected MetaBoxService $metaBoxService;
13
14
    protected SlugService $slugService;
15
16
    public function __construct(MetaBoxService $metaBoxService, SlugService $slugService)
17
    {
18
        $this->metaBoxService = $metaBoxService;
19
        $this->slugService = $slugService;
20
    }
21
22
    public function getMetaBoxBySlugModel(string $model, string $slug, string $lang = AppConstant::DEFAULT_LOCALE): ?Model
23
    {
24
        $slugModel = $this->slugService->getSlugModel($slug, $model);
25
26
        if ($slugModel) {
27
            return $this->metaBoxService->getMetaBoxByModel($model, $slugModel->reference_id, $lang);
28
        }
29
30
        return null;
31
    }
32
}
33