SheetCollectionNotFoundException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
eloc 10
c 1
b 0
f 1
dl 0
loc 28
ccs 12
cts 12
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setCollection() 0 5 1
A getSolution() 0 6 1
A make() 0 3 1
A getCollection() 0 3 1
1
<?php
2
3
namespace Astrotomic\Stancy\Exceptions;
4
5
use Facade\IgnitionContracts\BaseSolution;
6
use Facade\IgnitionContracts\ProvidesSolution;
7
use Facade\IgnitionContracts\Solution;
8
use RuntimeException;
9
10
class SheetCollectionNotFoundException extends RuntimeException implements ProvidesSolution
11
{
12
    /** @var string */
13
    protected $collection;
14
15 3
    public static function make(string $collection, ?RuntimeException $exception = null): self
16
    {
17 3
        return (new static("Sheet collection [{$collection}] does not exist.", 0, $exception))->setCollection($collection);
18
    }
19
20 2
    public function getCollection(): string
21
    {
22 2
        return $this->collection;
23
    }
24
25 3
    public function setCollection(string $collection): self
26
    {
27 3
        $this->collection = $collection;
28
29 3
        return $this;
30
    }
31
32 1
    public function getSolution(): Solution
33
    {
34 1
        return BaseSolution::create('The sheet collection is missing')
35 1
            ->setSolutionDescription("Add `{$this->getCollection()}` collection to your spatie/sheets configuration at `config/sheets.php`.\n```php\nreturn [\n// ...\n'collections' => ['{$this->getCollection()}'],\n// ...\n```")
36 1
            ->setDocumentationLinks([
37 1
                'Read spatie/sheets "Creating your first collection" documentation' => 'https://github.com/spatie/sheets#creating-your-first-collection',
38
            ]);
39
    }
40
}
41