@@ -26,13 +26,13 @@ class AuthUsersTable extends Table
2626 * Custom finder
2727 *
2828 * @param \Cake\ORM\Query\SelectQuery $query The query to find with
29- * @param array $options The options to find with
30- * @return \Cake\ORM\Query The query builder
29+ * @param bool $returnCreated Whether to return 'created' field.
30+ * @return \Cake\ORM\Query\SelectQuery The query builder
3131 */
32- public function findAuth (SelectQuery $ query , array $ options )
32+ public function findAuth (SelectQuery $ query , bool $ returnCreated = false ): SelectQuery
3333 {
3434 $ query ->select (['id ' , 'username ' , 'password ' ]);
35- if (! empty ( $ options [ ' return_created ' ]) ) {
35+ if ($ returnCreated ) {
3636 $ query ->select (['created ' ]);
3737 }
3838
@@ -43,19 +43,13 @@ public function findAuth(SelectQuery $query, array $options)
4343 * Custom finder
4444 *
4545 * @param \Cake\ORM\Query\SelectQuery $query The query to find with
46- * @param array $options The options to find with
47- * @return \Cake\ORM\Query The query builder
46+ * @param string $username String username
47+ * @return \Cake\ORM\Query\SelectQuery The query builder
4848 */
49- public function findUsername (SelectQuery $ query , array $ options )
49+ public function findUsername (SelectQuery $ query , string $ username ): SelectQuery
5050 {
51- if (empty ($ options ['username ' ])) {
52- throw new Exception ('Username not defined ' );
53- }
54-
55- $ query = $ this ->find ()
56- ->where (['username ' => $ options ['username ' ]])
51+ return $ this ->find ()
52+ ->where (['username ' => $ username ])
5753 ->select (['id ' , 'username ' , 'password ' ]);
58-
59- return $ query ;
6054 }
6155}
0 commit comments