triadev /
Leopard
| Conditions | 1 |
| Paths | 1 |
| Total Lines | 3 |
| Code Lines | 1 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 2 |
| CRAP Score | 1 |
| Changes | 0 | ||
| Metric | Value |
|---|---|
| cc | 1 |
| eloc | 1 |
| nc | 1 |
| nop | 0 |
| dl | 0 |
| loc | 3 |
| ccs | 2 |
| cts | 2 |
| cp | 1 |
| crap | 1 |
| rs | 10 |
| c | 0 |
| b | 0 |
| f | 0 |
| 1 | <?php |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 2 | namespace Triadev\Leopard\Business\Dsl; |
||
|
0 ignored issues
–
show
|
|||
| 3 | |||
| 4 | use ONGR\ElasticsearchDSL\Suggest\Suggest; |
||
| 5 | use Triadev\Leopard\Contract\ElasticsearchManagerContract; |
||
| 6 | use Triadev\Leopard\Facade\Leopard; |
||
| 7 | |||
| 8 | class Suggestion |
||
|
0 ignored issues
–
show
|
|||
| 9 | { |
||
|
0 ignored issues
–
show
|
|||
| 10 | /** @var \ONGR\ElasticsearchDSL\Search */ |
||
|
0 ignored issues
–
show
|
|||
| 11 | private $search; |
||
|
1 ignored issue
–
show
|
|||
| 12 | |||
| 13 | /** @var ElasticsearchManagerContract */ |
||
|
0 ignored issues
–
show
|
|||
| 14 | private $manager; |
||
|
0 ignored issues
–
show
|
|||
| 15 | |||
| 16 | /** |
||
| 17 | * Suggestion constructor. |
||
| 18 | * @param ElasticsearchManagerContract $manager |
||
|
0 ignored issues
–
show
|
|||
| 19 | * @param \ONGR\ElasticsearchDSL\Search|null $search |
||
|
0 ignored issues
–
show
|
|||
| 20 | */ |
||
| 21 | 3 | public function __construct( |
|
|
0 ignored issues
–
show
|
|||
| 22 | ElasticsearchManagerContract $manager, |
||
| 23 | ?\ONGR\ElasticsearchDSL\Search $search = null |
||
|
0 ignored issues
–
show
|
|||
| 24 | ) { |
||
|
0 ignored issues
–
show
|
|||
| 25 | 3 | $this->manager = $manager; |
|
| 26 | 3 | $this->search = $search ?: new \ONGR\ElasticsearchDSL\Search(); |
|
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 27 | 3 | } |
|
|
0 ignored issues
–
show
|
|||
| 28 | |||
| 29 | /** |
||
| 30 | * To dsl |
||
| 31 | * |
||
| 32 | * @return array |
||
| 33 | */ |
||
| 34 | 3 | public function toDsl(): array |
|
| 35 | { |
||
|
0 ignored issues
–
show
|
|||
| 36 | 3 | return $this->search->toArray(); |
|
| 37 | } |
||
|
0 ignored issues
–
show
|
|||
| 38 | |||
| 39 | /** |
||
| 40 | * Get |
||
| 41 | * |
||
| 42 | * @param string $index |
||
|
0 ignored issues
–
show
|
|||
| 43 | * @return array |
||
|
0 ignored issues
–
show
|
|||
| 44 | */ |
||
| 45 | public function get(string $index): array |
||
| 46 | { |
||
|
0 ignored issues
–
show
|
|||
| 47 | return Leopard::suggestStatement([ |
||
|
1 ignored issue
–
show
|
|||
| 48 | 'index' => $index, |
||
|
0 ignored issues
–
show
|
|||
| 49 | 'body' => $this->toDsl() |
||
|
0 ignored issues
–
show
|
|||
| 50 | ]); |
||
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||
| 51 | } |
||
|
0 ignored issues
–
show
|
|||
| 52 | |||
| 53 | /** |
||
| 54 | * Term |
||
| 55 | * |
||
| 56 | * @param string $name |
||
|
0 ignored issues
–
show
|
|||
| 57 | * @param string $text |
||
|
0 ignored issues
–
show
|
|||
| 58 | * @param string $field |
||
|
0 ignored issues
–
show
|
|||
| 59 | * @param array $params |
||
|
0 ignored issues
–
show
|
|||
| 60 | * @return Suggestion |
||
|
0 ignored issues
–
show
|
|||
| 61 | */ |
||
| 62 | 1 | public function term(string $name, string $text, string $field, array $params = []): Suggestion |
|
|
0 ignored issues
–
show
|
|||
| 63 | { |
||
|
0 ignored issues
–
show
|
|||
| 64 | 1 | $this->search->addSuggest(new Suggest( |
|
|
1 ignored issue
–
show
|
|||
| 65 | 1 | $name, |
|
| 66 | 1 | 'term', |
|
| 67 | 1 | $text, |
|
| 68 | 1 | $field, |
|
| 69 | 1 | $params |
|
| 70 | )); |
||
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||
| 71 | |||
| 72 | 1 | return $this; |
|
| 73 | } |
||
|
0 ignored issues
–
show
|
|||
| 74 | |||
| 75 | /** |
||
| 76 | * Phrase |
||
| 77 | * |
||
| 78 | * @param string $name |
||
|
0 ignored issues
–
show
|
|||
| 79 | * @param string $text |
||
|
0 ignored issues
–
show
|
|||
| 80 | * @param string $field |
||
|
0 ignored issues
–
show
|
|||
| 81 | * @param array $params |
||
|
0 ignored issues
–
show
|
|||
| 82 | * @return Suggestion |
||
|
0 ignored issues
–
show
|
|||
| 83 | */ |
||
| 84 | 1 | public function phrase(string $name, string $text, string $field, array $params = []): Suggestion |
|
|
0 ignored issues
–
show
|
|||
| 85 | { |
||
|
0 ignored issues
–
show
|
|||
| 86 | 1 | $this->search->addSuggest(new Suggest( |
|
|
1 ignored issue
–
show
|
|||
| 87 | 1 | $name, |
|
| 88 | 1 | 'phrase', |
|
| 89 | 1 | $text, |
|
| 90 | 1 | $field, |
|
| 91 | 1 | $params |
|
| 92 | )); |
||
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||
| 93 | |||
| 94 | 1 | return $this; |
|
| 95 | } |
||
|
0 ignored issues
–
show
|
|||
| 96 | |||
| 97 | /** |
||
| 98 | * Term |
||
| 99 | * |
||
| 100 | * @param string $name |
||
|
0 ignored issues
–
show
|
|||
| 101 | * @param string $text |
||
|
0 ignored issues
–
show
|
|||
| 102 | * @param string $field |
||
|
0 ignored issues
–
show
|
|||
| 103 | * @param array $params |
||
|
0 ignored issues
–
show
|
|||
| 104 | * @return Suggestion |
||
|
0 ignored issues
–
show
|
|||
| 105 | */ |
||
| 106 | 1 | public function completion(string $name, string $text, string $field, array $params = []): Suggestion |
|
|
0 ignored issues
–
show
|
|||
| 107 | { |
||
|
0 ignored issues
–
show
|
|||
| 108 | 1 | $this->search->addSuggest(new Suggest( |
|
|
1 ignored issue
–
show
|
|||
| 109 | 1 | $name, |
|
| 110 | 1 | 'completion', |
|
| 111 | 1 | $text, |
|
| 112 | 1 | $field, |
|
| 113 | 1 | $params |
|
| 114 | )); |
||
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||
| 115 | |||
| 116 | 1 | return $this; |
|
| 117 | } |
||
|
0 ignored issues
–
show
|
|||
| 118 | } |
||
|
0 ignored issues
–
show
|
|||
| 119 |