Skip to content

Commit

Permalink
add prettierrc and editorconfig for consistent formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
meszaros-lajos-gyorgy committed Nov 26, 2022
1 parent fcda92a commit 3180aef
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.php]
charset = utf-8
trim_trailing_whitespace = true
indent_style = space
indent_size = 4
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"printWidth": 120,
"phpVersion": "7.2",
"trailingCommaPHP": false,
"trailingComma": "none",
"semi": false,
"singleQuote": true,
"endOfLine": "lf"
}
3 changes: 2 additions & 1 deletion src/N.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Shovel;

class N {
class N
{
public static function toInt($n): ?int
{
return $n === null ? null : intval($n);
Expand Down
6 changes: 4 additions & 2 deletions src/S.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,14 @@ public static function trim(string $data): string
}

// S::replace("a", "b", "appletini") -> "bppletini"
public static function replace(string $old, string $new, string $data): string {
public static function replace(string $old, string $new, string $data): string
{
return str_replace($old, $new, $data);
}

// S::splitAt(3, "abcdef") -> ["abc", "def"]
public static function splitAt(int $index, string $data): array {
public static function splitAt(int $index, string $data): array
{
$first = self::slice(0, $index, $data);
$second = self::slice($index, PHP_INT_MAX, $data);
return [$first, $second];
Expand Down

0 comments on commit 3180aef

Please sign in to comment.