11<?php
22
3+ declare (strict_types=1 );
4+
35namespace librarianphp \Create ;
46
5- use Minicli \FileNotFoundException ;
6- use Minicli \Stencil ;
77use Minicli \Command \CommandController ;
8+ use Minicli \FileNotFoundException ;
89use Minicli \Input ;
10+ use Minicli \Stencil ;
911
1012class ContentController extends CommandController
1113{
@@ -14,41 +16,44 @@ class ContentController extends CommandController
1416 */
1517 public function handle (): void
1618 {
17- if (!$ this ->getApp ()->config ->has ('stencil_dir ' )) {
18- $ this ->error ("You must define a stencil_dir config option. " );
19+ if (! $ this ->getApp ()->config ->has ('stencil_dir ' )) {
20+ $ this ->error ('You must define a stencil_dir config option. ' );
21+
1922 return ;
2023 }
2124
22- if (!$ this ->getApp ()->config ->has ('stencil_locations ' )) {
23- $ this ->error ("You must define a stencil_locations array config option. " );
25+ if (! $ this ->getApp ()->config ->has ('stencil_locations ' )) {
26+ $ this ->error ('You must define a stencil_locations array config option. ' );
27+
2428 return ;
2529 }
2630
2731 $ args = $ this ->getArgs ();
2832 $ template_name = $ args [3 ] ?? null ;
29- if (!$ template_name ) {
33+ if (! $ template_name ) {
3034 $ template_name = 'post ' ;
3135 }
3236
3337 $ stencil = new Stencil ($ this ->getApp ()->config ->stencil_dir );
3438
3539 $ input = new Input (' ' );
3640
37- $ this ->info (" Content Title: " );
41+ $ this ->info (' Content Title: ' );
3842 $ title = $ input ->read ();
3943
40- $ this ->info (" Content Description: " );
44+ $ this ->info (' Content Description: ' );
4145 $ description = $ input ->read ();
4246
4347 $ content = $ stencil ->applyTemplate ($ template_name , [
4448 'title ' => $ title ,
45- 'description ' => $ description
49+ 'description ' => $ description,
4650 ]);
4751
4852 $ save_locations = $ this ->getApp ()->config ->stencil_locations ;
4953
50- if (!array_key_exists ($ template_name , $ save_locations )) {
51- $ this ->error ("Save location not found for template $ template_name " );
54+ if (! array_key_exists ($ template_name , $ save_locations )) {
55+ $ this ->error ("Save location not found for template {$ template_name }" );
56+
5257 return ;
5358 }
5459
@@ -57,7 +62,7 @@ public function handle(): void
5762 $ file = fopen ($ path . '/ ' . $ save_name , 'a+ ' );
5863
5964 fwrite ($ file , $ content );
60- $ this ->info (" Content generated at " . $ path . '/ ' . $ save_name );
65+ $ this ->info (' Content generated at ' . $ path . '/ ' . $ save_name );
6166 }
6267
6368 public function slugify ($ title )
0 commit comments