Issues (15)

src/Application/ReplaceAsset.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace Thinktomorrow\AssetLibrary\Application;
4
5
use Thinktomorrow\AssetLibrary\Asset;
6
use Thinktomorrow\AssetLibrary\HasAsset;
7
use Spatie\MediaLibrary\MediaCollections\Exceptions\FileCannotBeAdded;
8
9
class ReplaceAsset
10
{
11
    /**
12
     * Remove the asset and attaches a new one.
13
     *
14
     * @param $replace
15
     * @param $with
16
     * @param $type
17
     * @param $locale
18
     * @throws FileCannotBeAdded
19
     */
20 3
    public function handle(HasAsset $model, $replace, $with, $type, $locale)
21
    {
22 3
        $old = $model->assetRelation()->findOrFail($replace);
23
24 3
        app(AddAsset::class)->add($model, Asset::findOrFail($with), $type, $locale);
25
26 3
        app(DetachAsset::class)->detach($model, $old->id, $type, $locale);
0 ignored issues
show
The method detach() does not exist on Illuminate\Contracts\Foundation\Application. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        app(DetachAsset::class)->/** @scrutinizer ignore-call */ detach($model, $old->id, $type, $locale);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
The type Thinktomorrow\AssetLibrary\Application\DetachAsset 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...
27 3
    }
28
}
29