Skip to content

Commit edd1645

Browse files
Ellis KenyőHenrik Lissner
Ellis Kenyő
authored and
Henrik Lissner
committed
feat(+php-laravel-mode): add __ snippet
1 parent 6b2bd5a commit edd1645

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

+php-laravel-mode/.yas-parents.el

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
(eval-when-compile (require 'subr-x))
2+
3+
(defun +php-laravel-mode--get-namespace ()
4+
"Get a formatted namespace for the current PHP file"
5+
(substring
6+
(replace-regexp-in-string "/" (regexp-quote "\\")
7+
(thread-first
8+
buffer-file-name
9+
(file-relative-name (doom-project-root))
10+
file-name-directory
11+
capitalize))
12+
0
13+
-1))
14+
15+
(defun +php-laravel-mode--get-class-name ()
16+
"Get a formatted class name for the current PHP file"
17+
(string-join (mapcar 'capitalize
18+
(split-string
19+
(let ((case-fold-search nil))
20+
(replace-regexp-in-string
21+
"\\([[:lower:]]\\)\\([[:upper:]]\\)" "\\1 \\2"
22+
(replace-regexp-in-string
23+
"\\([[:upper:]]\\)\\([[:upper:]][0-9[:lower:]]\\)" "\\1 \\2"
24+
(file-name-base buffer-file-name))))
25+
"[^[:word:]0-9]+"
26+
t))))

+php-laravel-mode/__

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# -*- mode: snippet -*-
2+
# name: PHP template
3+
# --
4+
<?php
5+
6+
namespace `(+php-laravel-mode--get-namespace)`;
7+
8+
class `(+php-laravel-mode--get-class-name)`
9+
{
10+
$0
11+
}

0 commit comments

Comments
 (0)