| Conditions | 5 |
| Paths | 4 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public function RandomProduct() |
||
| 24 | { |
||
| 25 | $offSet = 0; |
||
| 26 | $product = true; |
||
| 27 | $notForSale = true; |
||
| 28 | while ($product && $notForSale) { |
||
| 29 | $notForSale = false; |
||
| 30 | $product = Product::get() |
||
| 31 | ->where('"AllowPurchase" = 1 AND "Price" > 0') |
||
| 32 | ->sort('RAND()') |
||
| 33 | ->limit(1, $offSet) |
||
| 34 | ->First(); |
||
| 35 | if ($product) { |
||
| 36 | $notForSale = $product->canPurchase() ? false : true; |
||
| 37 | } |
||
| 38 | ++$offSet; |
||
| 39 | } |
||
| 40 | |||
| 41 | return $product; |
||
| 42 | } |
||
| 43 | |||
| 68 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.