Skip to content

Commit d25500e

Browse files
committed
Added SampleController
1 parent d2a75e1 commit d25500e

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace App\Http\Controllers;
5+
6+
use Illuminate\Http\Request;
7+
use App\User;
8+
9+
class SampleController extends Controller
10+
{
11+
/**
12+
* @return int
13+
*/
14+
public function index()
15+
{
16+
$a = 1280;
17+
$b = 2500;
18+
19+
return $this->addition($a, $b);
20+
}
21+
22+
/**
23+
* 加算
24+
* @param int $a
25+
* @param int $b
26+
* @return int
27+
*/
28+
private function addition(int $a, int $b): int
29+
{
30+
return $a + $b;
31+
}
32+
33+
34+
/**
35+
* @return User
36+
* @throws \Exception
37+
*/
38+
public function get()
39+
{
40+
// レコードは id < 10 しか存在しないのに
41+
$user = User::where('id', 100)->first();
42+
43+
if(!$user) {
44+
throw new \Exception('User not found.');
45+
}
46+
47+
return $this->userOperation($user);
48+
}
49+
50+
/**
51+
* ユーザーデータを処理する(つもり)
52+
* @param User $user
53+
* @return User
54+
*/
55+
private function userOperation(User $user)
56+
{
57+
/*
58+
* 色々な処理...
59+
*/
60+
61+
return $user;
62+
}
63+
}

0 commit comments

Comments
 (0)