HtmlBlockTableSeeder   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
dl 0
loc 34
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 32 1
1
<?php
2
3
use Illuminate\Database\Seeder;
4
use Illuminate\Database\Eloquent\Model;
5
use Hideyo\Ecommerce\Framework\Services\Shop\Entity\Shop as Shop;
6
use Hideyo\Ecommerce\Framework\Services\HtmlBlock\Entity\HtmlBlock as HtmlBlock;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, HtmlBlock. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
7
8
class HtmlBlockTableSeeder extends Seeder
9
{
10
    public function run()
11
    {
12
        $htmlBlock = new HtmlBlock;
13
14
        DB::table($htmlBlock->getTable())->delete();
15
        $shop = Shop::where('title', '=', 'hideyo')->first();
16
17
        $htmlBlock->title = 'about us';
18
        $htmlBlock->active = 1;
19
        $htmlBlock->position = 'footer-about-us';
20
        $htmlBlock->content = '
21
            <h5>About us</h5>
22
            <p>
23
                Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer fermentum venenatis tempus. Suspendisse scelerisque urna bibendum pretium consectetur. Fusce eu enim tempus odio imperdiet pharetra. Ut varius nunc eget condimentum auctor. Morbi lacinia augue est, id tristique augue faucibus a.
24
            </p>';     
25
        $htmlBlock->shop_id = $shop->id;
26
        $htmlBlock->save();
27
28
        $htmlBlock2 = new HtmlBlock;
29
        $htmlBlock2->title = 'contact';
30
        $htmlBlock2->active = 1;
31
        $htmlBlock2->position = 'footer-contact';
32
        $htmlBlock2->content = '
33
              <h5>Contact</h5>
34
            <p>
35
                De Binderij 34<br>
36
                1321 EJ Almere<br>
37
                +31682008200<br>
38
                <a href="https://github.com/hideyo/ecommerce">github</a>
39
            </p>';     
40
        $htmlBlock2->shop_id = $shop->id;
41
        $htmlBlock2->save();
42
    }
43
}
44