Code Duplication    Length = 64-66 lines in 10 locations

src/Stream/Console/Command/WriteEntityCollection.php 1 location

@@ 14-77 (lines=64) @@
11
 * @author PyroCMS, Inc. <[email protected]>
12
 * @author Ryan Thompson <[email protected]>
13
 */
14
class WriteEntityCollection
15
{
16
17
    /**
18
     * The entity slug.
19
     *
20
     * @var string
21
     */
22
    private $slug;
23
24
    /**
25
     * The addon instance.
26
     *
27
     * @var Addon
28
     */
29
    private $addon;
30
31
    /**
32
     * The entity stream namespace.
33
     *
34
     * @var string
35
     */
36
    private $namespace;
37
38
39
    /**
40
     * Create a new WriteEntityCollection instance.
41
     *
42
     * @param Addon $addon
43
     * @param       $slug
44
     * @param       $namespace
45
     */
46
    public function __construct(Addon $addon, $slug, $namespace)
47
    {
48
        $this->slug      = $slug;
49
        $this->addon     = $addon;
50
        $this->namespace = $namespace;
51
    }
52
53
    /**
54
     * Handle the command.
55
     *
56
     * @param Parser     $parser
57
     * @param Filesystem $filesystem
58
     */
59
    public function handle(Parser $parser, Filesystem $filesystem)
60
    {
61
        $suffix = ucfirst(camel_case($this->slug));
62
        $entity = str_singular($suffix);
63
64
        $class     = "{$entity}Collection";
65
        $namespace = $this->addon->getTransformedClass("{$entity}");
66
67
        $path = $this->addon->getPath("src/{$entity}/{$entity}Collection.php");
68
69
        $template = $filesystem->get(
70
            base_path("vendor/anomaly/streams-platform/resources/stubs/entity/collection.stub")
71
        );
72
73
        $filesystem->makeDirectory(dirname($path), 0755, true, true);
74
75
        $filesystem->put($path, $parser->parse($template, compact('class', 'namespace')));
76
    }
77
}
78

src/Stream/Console/Command/WriteEntityCriteria.php 1 location

@@ 14-77 (lines=64) @@
11
 * @author PyroCMS, Inc. <[email protected]>
12
 * @author Ryan Thompson <[email protected]>
13
 */
14
class WriteEntityCriteria
15
{
16
17
    /**
18
     * The entity slug.
19
     *
20
     * @var string
21
     */
22
    private $slug;
23
24
    /**
25
     * The addon instance.
26
     *
27
     * @var Addon
28
     */
29
    private $addon;
30
31
    /**
32
     * The entity stream namespace.
33
     *
34
     * @var string
35
     */
36
    private $namespace;
37
38
39
    /**
40
     * Create a new WriteEntityCriteria instance.
41
     *
42
     * @param Addon $addon
43
     * @param       $slug
44
     * @param       $namespace
45
     */
46
    public function __construct(Addon $addon, $slug, $namespace)
47
    {
48
        $this->slug      = $slug;
49
        $this->addon     = $addon;
50
        $this->namespace = $namespace;
51
    }
52
53
    /**
54
     * Handle the command.
55
     *
56
     * @param Parser     $parser
57
     * @param Filesystem $filesystem
58
     */
59
    public function handle(Parser $parser, Filesystem $filesystem)
60
    {
61
        $suffix = ucfirst(camel_case($this->slug));
62
        $entity = str_singular($suffix);
63
64
        $class     = "{$entity}Criteria";
65
        $namespace = $this->addon->getTransformedClass("{$entity}");
66
67
        $path = $this->addon->getPath("src/{$entity}/{$entity}Criteria.php");
68
69
        $template = $filesystem->get(
70
            base_path("vendor/anomaly/streams-platform/resources/stubs/entity/criteria.stub")
71
        );
72
73
        $filesystem->makeDirectory(dirname($path), 0755, true, true);
74
75
        $filesystem->put($path, $parser->parse($template, compact('class', 'namespace')));
76
    }
77
}
78

src/Stream/Console/Command/WriteEntityFormBuilder.php 1 location

@@ 14-77 (lines=64) @@
11
 * @author PyroCMS, Inc. <[email protected]>
12
 * @author Ryan Thompson <[email protected]>
13
 */
14
class WriteEntityFormBuilder
15
{
16
17
    /**
18
     * The entity slug.
19
     *
20
     * @var string
21
     */
22
    private $slug;
23
24
    /**
25
     * The addon instance.
26
     *
27
     * @var Addon
28
     */
29
    private $addon;
30
31
    /**
32
     * The entity stream namespace.
33
     *
34
     * @var string
35
     */
36
    private $namespace;
37
38
39
    /**
40
     * Create a new WriteEntityFormBuilder instance.
41
     *
42
     * @param Addon $addon
43
     * @param       $slug
44
     * @param       $namespace
45
     */
46
    public function __construct(Addon $addon, $slug, $namespace)
47
    {
48
        $this->slug      = $slug;
49
        $this->addon     = $addon;
50
        $this->namespace = $namespace;
51
    }
52
53
    /**
54
     * Handle the command.
55
     *
56
     * @param Parser     $parser
57
     * @param Filesystem $filesystem
58
     */
59
    public function handle(Parser $parser, Filesystem $filesystem)
60
    {
61
        $suffix = ucfirst(camel_case($this->slug));
62
        $entity = str_singular($suffix);
63
64
        $class     = "{$entity}FormBuilder";
65
        $namespace = $this->addon->getTransformedClass("{$entity}\\Form");
66
67
        $path = $this->addon->getPath("src/{$entity}/Form/{$entity}FormBuilder.php");
68
69
        $template = $filesystem->get(
70
            base_path("vendor/anomaly/streams-platform/resources/stubs/entity/form/builder.stub")
71
        );
72
73
        $filesystem->makeDirectory(dirname($path), 0755, true, true);
74
75
        $filesystem->put($path, $parser->parse($template, compact('class', 'namespace')));
76
    }
77
}
78

src/Stream/Console/Command/WriteEntityModelInterface.php 1 location

@@ 14-77 (lines=64) @@
11
 * @author PyroCMS, Inc. <[email protected]>
12
 * @author Ryan Thompson <[email protected]>
13
 */
14
class WriteEntityModelInterface
15
{
16
17
    /**
18
     * The entity slug.
19
     *
20
     * @var string
21
     */
22
    private $slug;
23
24
    /**
25
     * The addon instance.
26
     *
27
     * @var Addon
28
     */
29
    private $addon;
30
31
    /**
32
     * The entity stream namespace.
33
     *
34
     * @var string
35
     */
36
    private $namespace;
37
38
39
    /**
40
     * Create a new WriteEntityModelInterface instance.
41
     *
42
     * @param Addon $addon
43
     * @param       $slug
44
     * @param       $namespace
45
     */
46
    public function __construct(Addon $addon, $slug, $namespace)
47
    {
48
        $this->slug      = $slug;
49
        $this->addon     = $addon;
50
        $this->namespace = $namespace;
51
    }
52
53
    /**
54
     * Handle the command.
55
     *
56
     * @param Parser     $parser
57
     * @param Filesystem $filesystem
58
     */
59
    public function handle(Parser $parser, Filesystem $filesystem)
60
    {
61
        $suffix = ucfirst(camel_case($this->slug));
62
        $entity = str_singular($suffix);
63
64
        $class     = "{$entity}Interface";
65
        $namespace = $this->addon->getTransformedClass("{$entity}\\Contract");
66
67
        $path = $this->addon->getPath("src/{$entity}/Contract/{$entity}Interface.php");
68
69
        $template = $filesystem->get(
70
            base_path("vendor/anomaly/streams-platform/resources/stubs/entity/contract/entry.stub")
71
        );
72
73
        $filesystem->makeDirectory(dirname($path), 0755, true, true);
74
75
        $filesystem->put($path, $parser->parse($template, compact('class', 'namespace')));
76
    }
77
}
78

src/Stream/Console/Command/WriteEntityObserver.php 1 location

@@ 14-77 (lines=64) @@
11
 * @author PyroCMS, Inc. <[email protected]>
12
 * @author Ryan Thompson <[email protected]>
13
 */
14
class WriteEntityObserver
15
{
16
17
    /**
18
     * The entity slug.
19
     *
20
     * @var string
21
     */
22
    private $slug;
23
24
    /**
25
     * The addon instance.
26
     *
27
     * @var Addon
28
     */
29
    private $addon;
30
31
    /**
32
     * The entity stream namespace.
33
     *
34
     * @var string
35
     */
36
    private $namespace;
37
38
39
    /**
40
     * Create a new WriteEntityObserver instance.
41
     *
42
     * @param Addon $addon
43
     * @param       $slug
44
     * @param       $namespace
45
     */
46
    public function __construct(Addon $addon, $slug, $namespace)
47
    {
48
        $this->slug      = $slug;
49
        $this->addon     = $addon;
50
        $this->namespace = $namespace;
51
    }
52
53
    /**
54
     * Handle the command.
55
     *
56
     * @param Parser     $parser
57
     * @param Filesystem $filesystem
58
     */
59
    public function handle(Parser $parser, Filesystem $filesystem)
60
    {
61
        $suffix = ucfirst(camel_case($this->slug));
62
        $entity = str_singular($suffix);
63
64
        $class     = "{$entity}Observer";
65
        $namespace = $this->addon->getTransformedClass("{$entity}");
66
67
        $path = $this->addon->getPath("src/{$entity}/{$entity}Observer.php");
68
69
        $template = $filesystem->get(
70
            base_path("vendor/anomaly/streams-platform/resources/stubs/entity/observer.stub")
71
        );
72
73
        $filesystem->makeDirectory(dirname($path), 0755, true, true);
74
75
        $filesystem->put($path, $parser->parse($template, compact('class', 'namespace')));
76
    }
77
}
78

src/Stream/Console/Command/WriteEntityPresenter.php 1 location

@@ 14-77 (lines=64) @@
11
 * @author PyroCMS, Inc. <[email protected]>
12
 * @author Ryan Thompson <[email protected]>
13
 */
14
class WriteEntityPresenter
15
{
16
17
    /**
18
     * The entity slug.
19
     *
20
     * @var string
21
     */
22
    private $slug;
23
24
    /**
25
     * The addon instance.
26
     *
27
     * @var Addon
28
     */
29
    private $addon;
30
31
    /**
32
     * The entity stream namespace.
33
     *
34
     * @var string
35
     */
36
    private $namespace;
37
38
39
    /**
40
     * Create a new WriteEntityPresenter instance.
41
     *
42
     * @param Addon $addon
43
     * @param       $slug
44
     * @param       $namespace
45
     */
46
    public function __construct(Addon $addon, $slug, $namespace)
47
    {
48
        $this->slug      = $slug;
49
        $this->addon     = $addon;
50
        $this->namespace = $namespace;
51
    }
52
53
    /**
54
     * Handle the command.
55
     *
56
     * @param Parser     $parser
57
     * @param Filesystem $filesystem
58
     */
59
    public function handle(Parser $parser, Filesystem $filesystem)
60
    {
61
        $suffix = ucfirst(camel_case($this->slug));
62
        $entity = str_singular($suffix);
63
64
        $class     = "{$entity}Presenter";
65
        $namespace = $this->addon->getTransformedClass("{$entity}");
66
67
        $path = $this->addon->getPath("src/{$entity}/{$entity}Presenter.php");
68
69
        $template = $filesystem->get(
70
            base_path("vendor/anomaly/streams-platform/resources/stubs/entity/presenter.stub")
71
        );
72
73
        $filesystem->makeDirectory(dirname($path), 0755, true, true);
74
75
        $filesystem->put($path, $parser->parse($template, compact('class', 'namespace')));
76
    }
77
}
78

src/Stream/Console/Command/WriteEntityRepositoryInterface.php 1 location

@@ 14-77 (lines=64) @@
11
 * @author PyroCMS, Inc. <[email protected]>
12
 * @author Ryan Thompson <[email protected]>
13
 */
14
class WriteEntityRepositoryInterface
15
{
16
17
    /**
18
     * The entity slug.
19
     *
20
     * @var string
21
     */
22
    private $slug;
23
24
    /**
25
     * The addon instance.
26
     *
27
     * @var Addon
28
     */
29
    private $addon;
30
31
    /**
32
     * The entity stream namespace.
33
     *
34
     * @var string
35
     */
36
    private $namespace;
37
38
39
    /**
40
     * Create a new WriteEntityRepositoryInterface instance.
41
     *
42
     * @param Addon $addon
43
     * @param       $slug
44
     * @param       $namespace
45
     */
46
    public function __construct(Addon $addon, $slug, $namespace)
47
    {
48
        $this->slug      = $slug;
49
        $this->addon     = $addon;
50
        $this->namespace = $namespace;
51
    }
52
53
    /**
54
     * Handle the command.
55
     *
56
     * @param Parser     $parser
57
     * @param Filesystem $filesystem
58
     */
59
    public function handle(Parser $parser, Filesystem $filesystem)
60
    {
61
        $suffix = ucfirst(camel_case($this->slug));
62
        $entity = str_singular($suffix);
63
64
        $class     = "{$entity}RepositoryInterface";
65
        $namespace = $this->addon->getTransformedClass("{$entity}\\Contract");
66
67
        $path = $this->addon->getPath("src/{$entity}/Contract/{$entity}RepositoryInterface.php");
68
69
        $template = $filesystem->get(
70
            base_path("vendor/anomaly/streams-platform/resources/stubs/entity/contract/repository.stub")
71
        );
72
73
        $filesystem->makeDirectory(dirname($path), 0755, true, true);
74
75
        $filesystem->put($path, $parser->parse($template, compact('class', 'namespace')));
76
    }
77
}
78

src/Stream/Console/Command/WriteEntityRouter.php 1 location

@@ 14-77 (lines=64) @@
11
 * @author PyroCMS, Inc. <[email protected]>
12
 * @author Ryan Thompson <[email protected]>
13
 */
14
class WriteEntityRouter
15
{
16
17
    /**
18
     * The entity slug.
19
     *
20
     * @var string
21
     */
22
    private $slug;
23
24
    /**
25
     * The addon instance.
26
     *
27
     * @var Addon
28
     */
29
    private $addon;
30
31
    /**
32
     * The entity stream namespace.
33
     *
34
     * @var string
35
     */
36
    private $namespace;
37
38
39
    /**
40
     * Create a new WriteEntityRouter instance.
41
     *
42
     * @param Addon $addon
43
     * @param       $slug
44
     * @param       $namespace
45
     */
46
    public function __construct(Addon $addon, $slug, $namespace)
47
    {
48
        $this->slug      = $slug;
49
        $this->addon     = $addon;
50
        $this->namespace = $namespace;
51
    }
52
53
    /**
54
     * Handle the command.
55
     *
56
     * @param Parser     $parser
57
     * @param Filesystem $filesystem
58
     */
59
    public function handle(Parser $parser, Filesystem $filesystem)
60
    {
61
        $suffix = ucfirst(camel_case($this->slug));
62
        $entity = str_singular($suffix);
63
64
        $class     = "{$entity}Router";
65
        $namespace = $this->addon->getTransformedClass("{$entity}");
66
67
        $path = $this->addon->getPath("src/{$entity}/{$entity}Router.php");
68
69
        $template = $filesystem->get(
70
            base_path("vendor/anomaly/streams-platform/resources/stubs/entity/router.stub")
71
        );
72
73
        $filesystem->makeDirectory(dirname($path), 0755, true, true);
74
75
        $filesystem->put($path, $parser->parse($template, compact('class', 'namespace')));
76
    }
77
}
78

src/Stream/Console/Command/WriteEntityTableBuilder.php 1 location

@@ 14-77 (lines=64) @@
11
 * @author PyroCMS, Inc. <[email protected]>
12
 * @author Ryan Thompson <[email protected]>
13
 */
14
class WriteEntityTableBuilder
15
{
16
17
    /**
18
     * The entity slug.
19
     *
20
     * @var string
21
     */
22
    private $slug;
23
24
    /**
25
     * The addon instance.
26
     *
27
     * @var Addon
28
     */
29
    private $addon;
30
31
    /**
32
     * The entity stream namespace.
33
     *
34
     * @var string
35
     */
36
    private $namespace;
37
38
39
    /**
40
     * Create a new WriteEntityTableBuilder instance.
41
     *
42
     * @param Addon $addon
43
     * @param       $slug
44
     * @param       $namespace
45
     */
46
    public function __construct(Addon $addon, $slug, $namespace)
47
    {
48
        $this->slug      = $slug;
49
        $this->addon     = $addon;
50
        $this->namespace = $namespace;
51
    }
52
53
    /**
54
     * Handle the command.
55
     *
56
     * @param Parser     $parser
57
     * @param Filesystem $filesystem
58
     */
59
    public function handle(Parser $parser, Filesystem $filesystem)
60
    {
61
        $suffix = ucfirst(camel_case($this->slug));
62
        $entity = str_singular($suffix);
63
64
        $class     = "{$entity}TableBuilder";
65
        $namespace = $this->addon->getTransformedClass("{$entity}\\Table");
66
67
        $path = $this->addon->getPath("src/{$entity}/Table/{$entity}TableBuilder.php");
68
69
        $template = $filesystem->get(
70
            base_path("vendor/anomaly/streams-platform/resources/stubs/entity/table/builder.stub")
71
        );
72
73
        $filesystem->makeDirectory(dirname($path), 0755, true, true);
74
75
        $filesystem->put($path, $parser->parse($template, compact('class', 'namespace')));
76
    }
77
}
78

src/Stream/Console/Command/WriteEntitySeeder.php 1 location

@@ 15-80 (lines=66) @@
12
 *
13
 * @link   http://pyrocms.com/
14
 */
15
class WriteEntitySeeder
16
{
17
18
    /**
19
     * The entity slug.
20
     *
21
     * @var string
22
     */
23
    private $slug;
24
25
    /**
26
     * The addon instance.
27
     *
28
     * @var Addon
29
     */
30
    private $addon;
31
32
    /**
33
     * The entity stream namespace.
34
     *
35
     * @var string
36
     */
37
    private $namespace;
38
39
    /**
40
     * Create a new WriteEntitySeeder instance.
41
     *
42
     * @param Addon        $addon
43
     * @param $slug
44
     * @param $namespace
45
     */
46
    public function __construct(Addon $addon, $slug, $namespace)
47
    {
48
        $this->slug      = $slug;
49
        $this->addon     = $addon;
50
        $this->namespace = $namespace;
51
    }
52
53
    /**
54
     * Handle the command.
55
     *
56
     * @param Parser     $parser
57
     * @param Filesystem $filesystem
58
     */
59
    public function handle(Parser $parser, Filesystem $filesystem)
60
    {
61
        $entities = camel_case($this->slug);
62
        $suffix   = ucfirst($entities);
63
        $entity   = str_singular($suffix);
64
65
        $class     = "{$entity}Seeder";
66
        $namespace = $this->addon->getTransformedClass("{$entity}");
67
68
        $path = $this->addon->getPath("src/{$entity}/{$entity}Seeder.php");
69
70
        $template = $filesystem->get(
71
            base_path('vendor/anomaly/streams-platform/resources/stubs/entity/seeder.stub')
72
        );
73
74
        $filesystem->makeDirectory(dirname($path), 0755, true, true);
75
76
        $filesystem->put($path, $parser->parse(
77
            $template,
78
            compact('class', 'namespace', 'entity', 'entities')));
79
    }
80
}
81