-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenerator_Command.php
More file actions
48 lines (38 loc) · 1.15 KB
/
Copy pathGenerator_Command.php
File metadata and controls
48 lines (38 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Tribe\Libs\Generators;
use Tribe\Libs\CLI\Command;
abstract class Generator_Command extends Command {
protected $file_system = null;
protected $templates_path = '';
protected $src_path = '';
/**
* Generator_Command constructor.
*
* @param File_System $file_system
* @param string $src_path Path to the core plugin's src directory
*/
public function __construct( File_System $file_system, $src_path ) {
$this->file_system = $file_system;
$this->templates_path = trailingslashit( __DIR__ ) . 'templates/';
$this->src_path = trailingslashit( $src_path );
parent::__construct();
}
/**
* converts a multi-word lowercase _ separated slug in
* multi-word upper case first format.
*
* multi_word_slug becomes Multi_Word_Slug
*
* @param string $slug lowercase words separated by _.
*
* @return string
*/
public function ucwords( $slug ) {
$uc_words = array_map( fn( $word ) => ucfirst( $word ), explode( '_', $slug ) );
return implode( '_', $uc_words );
}
protected function sanitize_slug( $args ) {
[ $slug ] = $args;
return str_replace( '-', '_', sanitize_title( $slug ) );
}
}