@@ -13,8 +13,8 @@ class CacheKey
1313 protected function getCachePrefix () : string
1414 {
1515 return "genealabs:laravel-model-caching: "
16- . (config (' laravel-model-caching.cache-prefix ' )
17- ? config (' laravel-model-caching.cache-prefix ' , '' ) . ": "
16+ . (config (" laravel-model-caching.cache-prefix " )
17+ ? config (" laravel-model-caching.cache-prefix " , "" ) . ": "
1818 : "" );
1919 }
2020
@@ -29,13 +29,13 @@ public function __construct(
2929 }
3030
3131 public function make (
32- array $ columns = [' * ' ],
32+ array $ columns = [" * " ],
3333 $ idColumn = null ,
34- string $ keyDifferentiator = ''
34+ string $ keyDifferentiator = ""
3535 ) : string {
3636 $ key = $ this ->getCachePrefix ();
3737 $ key .= $ this ->getModelSlug ();
38- $ key .= $ this ->getIdColumn ($ idColumn ?: '' );
38+ $ key .= $ this ->getIdColumn ($ idColumn ?: "" );
3939 $ key .= $ this ->getQueryColumns ($ columns );
4040 $ key .= $ this ->getWhereClauses ();
4141 $ key .= $ this ->getWithModels ();
@@ -49,13 +49,13 @@ public function make(
4949
5050 protected function getIdColumn (string $ idColumn ) : string
5151 {
52- return $ idColumn ? "_ {$ idColumn }" : '' ;
52+ return $ idColumn ? "_ {$ idColumn }" : "" ;
5353 }
5454
5555 protected function getLimitClause () : string
5656 {
5757 if (! $ this ->query ->limit ) {
58- return '' ;
58+ return "" ;
5959 }
6060
6161 return "-limit_ {$ this ->query ->limit }" ;
@@ -69,7 +69,7 @@ protected function getModelSlug() : string
6969 protected function getOffsetClause () : string
7070 {
7171 if (! $ this ->query ->offset ) {
72- return '' ;
72+ return "" ;
7373 }
7474
7575 return "-offset_ {$ this ->query ->offset }" ;
@@ -81,48 +81,48 @@ protected function getOrderByClauses() : string
8181
8282 return $ orders
8383 ->reduce (function ($ carry , $ order ) {
84- if (($ order [' type ' ] ?? '' ) === ' Raw ' ) {
85- return $ carry . ' _orderByRaw_ ' . str_slug ($ order [' sql ' ]);
84+ if (($ order [" type " ] ?? "" ) === " Raw " ) {
85+ return $ carry . " _orderByRaw_ " . str_slug ($ order [" sql " ]);
8686 }
8787
88- return $ carry . ' _orderBy_ ' . $ order [' column ' ] . ' _ ' . $ order [' direction ' ];
88+ return $ carry . " _orderBy_ " . $ order [" column " ] . " _ " . $ order [" direction " ];
8989 })
90- ?: '' ;
90+ ?: "" ;
9191 }
9292
9393 protected function getQueryColumns (array $ columns ) : string
9494 {
95- if ($ columns === [' * ' ] || $ columns === []) {
96- return '' ;
95+ if ($ columns === [" * " ] || $ columns === []) {
96+ return "" ;
9797 }
9898
99- return ' _ ' . implode (' _ ' , $ columns );
99+ return " _ " . implode (" _ " , $ columns );
100100 }
101101
102102 protected function getTypeClause ($ where ) : string
103103 {
104- $ type =in_array ($ where [' type ' ], [' In ' , ' NotIn ' , ' Null ' , ' NotNull ' , ' between ' ])
105- ? strtolower ($ where [' type ' ])
106- : strtolower ($ where [' operator ' ]);
104+ $ type =in_array ($ where [" type " ], [" In " , " NotIn " , " Null " , " NotNull " , " between " ])
105+ ? strtolower ($ where [" type " ])
106+ : strtolower ($ where [" operator " ]);
107107
108- return str_replace (' ' , ' _ ' , $ type );
108+ return str_replace (" " , " _ " , $ type );
109109 }
110110
111111 protected function getValuesClause (array $ where = null ) : string
112112 {
113- if (in_array ($ where [' type ' ], [' NotNull ' ])) {
114- return '' ;
113+ if (in_array ($ where [" type " ], [" NotNull " ])) {
114+ return "" ;
115115 }
116116
117- $ values = is_array (array_get ($ where , ' values ' ))
118- ? implode (' _ ' , $ where [' values ' ])
119- : '' ;
117+ $ values = is_array (array_get ($ where , " values " ))
118+ ? implode (" _ " , $ where [" values " ])
119+ : "" ;
120120
121- if (! $ values && $ this ->query ->bindings [' where ' ] ?? false ) {
122- $ values = implode (' _ ' , $ this ->query ->bindings [' where ' ]);
121+ if (! $ values && $ this ->query ->bindings [" where " ] ?? false ) {
122+ $ values = implode (" _ " , $ this ->query ->bindings [" where " ]);
123123 }
124124
125- return ' _ ' . $ values ;
125+ return " _ " . $ values ;
126126 }
127127
128128 protected function getWhereClauses (array $ wheres = []) : string
@@ -136,46 +136,46 @@ protected function getWhereClauses(array $wheres = []) : string
136136
137137 return $ value ;
138138 })
139- . '' ;
139+ . "" ;
140140 }
141141
142142 protected function getNestedClauses (array $ where ) : string
143143 {
144- if (! in_array ($ where [' type ' ], [' Exists ' , ' Nested ' , ' NotExists ' ])) {
145- return '' ;
144+ if (! in_array ($ where [" type " ], [" Exists " , " Nested " , " NotExists " ])) {
145+ return "" ;
146146 }
147147
148- return ' _ ' . strtolower ($ where [' type ' ]) . $ this ->getWhereClauses ($ where [' query ' ]->wheres );
148+ return " _ " . strtolower ($ where [" type " ]) . $ this ->getWhereClauses ($ where [" query " ]->wheres );
149149 }
150150
151151 protected function getColumnClauses (array $ where ) : string
152152 {
153- if ($ where [' type ' ] !== ' Column ' ) {
154- return '' ;
153+ if ($ where [" type " ] !== " Column " ) {
154+ return "" ;
155155 }
156156
157- return "_ {$ where [' boolean ' ]}_ {$ where [' first ' ]}_ {$ where [' operator ' ]}_ {$ where [' second ' ]}" ;
157+ return "_ {$ where [" boolean " ]}_ {$ where [" first " ]}_ {$ where [" operator " ]}_ {$ where [" second " ]}" ;
158158 }
159159
160160 protected function getRawClauses (array $ where ) : string
161161 {
162- if ($ where [' type ' ] !== ' raw ' ) {
163- return '' ;
162+ if ($ where [" type " ] !== " raw " ) {
163+ return "" ;
164164 }
165165
166- return "_ {$ where [' boolean ' ]}_ " . str_slug ($ where [' sql ' ]);
166+ return "_ {$ where [" boolean " ]}_ " . str_slug ($ where [" sql " ]);
167167 }
168168
169169 protected function getOtherClauses (array $ where , string $ carry = null ) : string
170170 {
171- if (in_array ($ where [' type ' ], [' Exists ' , ' Nested ' , ' NotExists ' , ' raw ' , ' Column ' ])) {
172- return '' ;
171+ if (in_array ($ where [" type " ], [" Exists " , " Nested " , " NotExists " , " raw " , " Column " ])) {
172+ return "" ;
173173 }
174174
175175 $ value = $ this ->getTypeClause ($ where );
176176 $ value .= $ this ->getValuesClause ($ where );
177177
178- return "{$ carry }- {$ where [' column ' ]}_ {$ value }" ;
178+ return "{$ carry }- {$ where [" column " ]}_ {$ value }" ;
179179 }
180180
181181 protected function getWheres (array $ wheres ) : Collection
@@ -194,9 +194,9 @@ protected function getWithModels() : string
194194 $ eagerLoads = collect ($ this ->eagerLoad );
195195
196196 if ($ eagerLoads ->isEmpty ()) {
197- return '' ;
197+ return "" ;
198198 }
199199
200- return ' - ' . implode (' - ' , $ eagerLoads ->keys ()->toArray ());
200+ return " - " . implode (" - " , $ eagerLoads ->keys ()->toArray ());
201201 }
202202}
0 commit comments