Skip to content

Latest commit

 

History

History
executable file
·
88 lines (84 loc) · 20.8 KB

list-of-keywords-in-rule.md

File metadata and controls

executable file
·
88 lines (84 loc) · 20.8 KB

|

Keywords Description
also `also` filler word like all other filler words does not come with any side effects but is used sorely for readability purposes. eg: `->beforeCreating()->assign("hello")->to($text)->convertToUpperCase()->reverseString()->storeAs($text)->succeedWith($text)` this can be rewritten as `beforeCreating()->assign("hello")->to($text)->convertToUpperCase()->also->reverseString()->storeAs($text)->succeedWith($text)` notice the introduction of the `also` keyword, this does not change the end results but just makes it more readable. @return $this
then `then` filler word like all other filler words does not come with any side effects but is used solely for readability purposes. eg: `->beforeCreating()->assign("hello")->to($text)->convertToUpperCase()->reverseString()->storeAs($text)->succeedWith($text)` this can be rewritten as `beforeCreating()->assign("hello")->to($text)->convertToUpperCase()->then->reverseString()->storeAs($text)->succeedWith($text)` notice the introduction of the `then` keyword, this does not change the end results but just makes it more readable. @return $this
firstly `firstly` filler word like all other filler words does not come with any side effects but is used solely for readability purposes eg: `->beforeCreating()->firstly->assign("hello")->to($text)->secondly->convertToUpperCase()->then->storeAs($text)->lastly->succeedWith($text)`. @return $this
Secondly `secondly` filler word like all other filler words does not come with any side effects but is used solely for readability purposes eg: `->beforeCreating()->firstly->assign("hello")->to($text)->secondly->convertToUpperCase()->then->storeAs($text)->lastly->succeedWith($text)`. @return $this
thirdly `thirdly` filler word like all other filler words does not come with any side effects but is used solely for readability purposes eg: `->beforeCreating()->firstly->assign("hello")->to($text)->secondly->convertToUpperCase()->then->storeAs($text)->lastly->succeedWith($text)`. @return $this
lastly `lastly` filler word like all other filler words does not come with any side effects but is used solely for readability purposes eg: `->beforeCreating()->firstly->assign("hello")->to($text)->secondly->convertToUpperCase()->then->storeAs($text)->lastly->succeedWith($text)`. @return $this
beSureTo `beSureTo` filler word like all other filler words does not come with any side effects but is used solely for readability purposes eg: `->beforeCreating()->firstly->assign("hello")->to($text)->secondly->convertToUpperCase()->then->beSureTo->storeAs($text)->lastly->succeedWith($text)`. @return $this
next `next` filler word like all other filler words does not come with any side effects but is used solely for readability purposes eg: `->beforeCreating()->firstly->assign("hello")->to($text)->secondly->convertToUpperCase()->next->storeAs($text)->lastly->succeedWith($text)`. @return $this
authenticateUser Appending the authenticateUser method to any query action will force users to login to gain access to the system eg: ->beforeQuerying()->onTable('subscriptions')->autheticateUser() @return $this
denyExternalAccess In the event you do not want to grant external access to a table to any users you should use `denyExternalAccess` method . `->beforeQuerying()->onTable('subscriptions')->denyExternalAccess()` In this case no user will be able to access the `subscriptions` table @return $this
allowExternalAccess You may decide to set all your table access to either `authenticated` or `private` from within the `privacy tab` but then decide to make one or more tables public in this case use the `allowExternalAccess` method `->beforeQuerying()->onTable('news', 'tariffs')->allowExternalAccess()` @return $this
grantOnlyAdminAccess You may decide to provide access of some tables to just the admin instead locking them up totally . To do this use the `grantOnlyAdminAccess` method.`->beforeQuerying()->onTable('news', 'tariffs')->grantOnlyAdminAccess()` @return $this
onQuery Checks if a table is being queried for data then the code attached to it will run. This will run twice before and after the data is being queried. @return $this
onUpdate Checks if data is being updated on a table then the code attached to it will run.This will run twice before and after the data is being updated. @return $this
onCreate Checks if data is being added to table then the code attached to it will run. This will run twice before and after the data is being added @return $this
onDelete Check if data is being deleted from a table. This will run code attached to it before and after its being run @return $this
beforeQuerying Checks if a table is about to be queried for data .The code attached to it will run before the data is queried @return $this
beforeCreating Checks if data is about to be added to a table and runs the code attached to it before this happens @return $this
beforeUpdating Checks if table data is about to be updated, and will run the code attached to it before the action is performed @return $this
beforeDeleting Check if data is about to be deleted from table. Then run the code attached to the action before its being performed. This allows you to perform actions such as `afterQuering()->mutateResponseMessage("the response message has been altered") @return $this
afterQuerying Runs code attached to this method just before the response is being returned to the client. This allows you to perform actions such as `afterQuering()->whenever($rules->status_code == 625)->mutateResponseMessage("the response message has been altered") @return $this
afterCreating Runs code attached to this method after the data has been added to the DB. This allows you to perform actions such as `afterCreating()->whenever($rules->status_code == 625)->mutateResponseMessage("the response message has been altered") @return $this
afterUpdating Run code attached to this method after the data has been updated . This allows you to perform actions such as `afterUpdating()->whenever($rules->status_code == 619)->mutateResponseMessage("the response message has been altered") @return $this
afterDeleting Runs code attached to the `afterDeleting()` method. This allows you to perform actions such as `afterDeleting()->whenever($rules->status_code == 636)->mutateResponseMessage("the response message has been altered") @return $this
onAnyReequest Code attached to the `onAnyRequest()` will run regardless of whether its a query, create delete or update action @return $this
whenever This is the equivalence of if and is mostly used together with assertions to alter execution flows. eg beforeQuerying()->whenever(assertIts::equal($input_name, "edmond"))->then->succeedWith("yes the names are same") @param $assertion @return $this
elseWhenever This is the equivalence of elseif and is mostly used together with assertions to alter execution flows eg.beforeQuerying()->whenever(assertIts::equal($input_name, "edmond"))->then->succeedWith("yes the names are same")->elseWhenever(assertIts::equal($input_name, "charles")))->then->succeedWith("yes the names are charles") @param $assertion @return $this
otherwise This is the equivalence of else eg.beforeQuerying()->whenever(assertIts::equal($input_name, "edmond"))->then->succeedWith("yes the names are same")->elseWhenever(assertIts::equal($input_name, "charles")))->then->succeedWith("yes the names are charles")->otherwise()->succeedWith("Its some other name") @return $this
onTable Checks if the db action to be conducted around one of the tables. Eg beforeQuerying()->onTable('register', 'subscription')->succeedWith("yes"). In the example above yes will be outputted in case data is being queried from either register or subscription table. @param string $expectedTableName @return mixed|
succeedWith Stop execution with an exception and output the message provided. Eg. afterQuering()->succeedWith("I will show up after quering") @param null $msg @return mixed|
failWith Stop execution with an exception and output the message provided. Eg. afterQuering()->failWith("I will show up after quering"). Difference between this and succeedWith is the status code @param string $msg @return mixed|
run DevLess provides developers with ready to use code and one of the ways to access this is via the run statement. After installing an external service you may call it within the rules portion of your app using run eg: beforeCreating()->run('businessMath','discount',[10, $input_price])->getResults($input_price) @param $service @param $method @param array $params @return mixed|
makeExternalRequest In the event where you need to make say an api call, the `makeExternalRequest` method becomes handy. eg beforeUpdating()->makeExternalRequest('GET', 'https://www.calcatraz.com/calculator/api?c=3%2A3')->storeAs($ans) ->succeedWith($ans) @param STRING $method @param STRING $url @param JSON $data (opt) @param JSON $headers (optional) @return $this @param STRING $method @param STRING $url @param JSON $data (opt) @param JSON $headers (optional) @return $this
getResults one of the ways to store results from a method with output is by using the `getResults` method. This will allow you to the output of a method @param $input_var @return $this
storeAs Get results from the last executed method and assign to a variable. eg: beforeQuerying()->sumUp(1.2,3,4,5)->storeAs($ans)->stopAndOutput(1001, 'summed up numbers successfully' $ans) @param $input_var @return $this
assign Assigns one variable to another just like `$sum2 = $sum` . This method works together with `to` method to achive this. eg: afterQuering()->sumUp(1,2,3,4,5)->storeAs($sum)->assign($sum)->to($sum2)->succeedWith($sum2) @param $input_var @return $this
usingService Set the name of service from which you want to use method from. * eg: usingService('devless')->callMethod('hello')-> withParams()->getResults($output)->succeedWith($output) @param $serviceName @return $this
callMethod Set the name of the method after setting the service from which you will like to run. eg:usingService('devless')->callMethod('hello')-> withParams()->getResults($output)->succeedWith($output) @param $methodName @return $this
withParams Set parameters for method from which you will like to run eg: usingService('devless')->callMethod('getUserProfile')-> withParams(1)->getResults($output)->succeedWith($output) @param can have n number of parameters @return $this
withoutParams Use this in place of `params()` in case the service method you want to run has no parameters eg: usingService('devless')->callMethod('hello')->withoutParams()->getResults($output)->succeedWith($output) @return $this
to `to` keyword should be used together with `assign` to assign either variables or values to a new variable @param $output @return $this
assignValues Behaves just like the `assign` method but has a much shorter construct. where you will assign say the string "edmond" to variable $name using `assign` `assign("edmond")->to($name)` , `assignValue("edmond", $name)` provides a much shorter construct but loses its redability. @param $input @param $output @return $this
stopAndOutput Should you perform some rules and based on that will like to exit earlier with a response before the actual db command completes, you will want to use `stopAndOutput` eg: beforeQuerying()->usingService('devless')->callMethod('getUserProfile')->withParams(1)->storeAs($profile)->stopAndOutput(1000, 'got profile successfully', $profile). @param $status_code @param $message @param $payload @return $this
help List out all methods as well as get docs on specific method eg: ->help('stopAndOutput') @param $methodToGetDocsFor @return $this
calculate Perform mathematical operations eg: `->beforeQuerying()->calculate(3*5)->storeAs($ans)->stopAndOutput(1001,'got answer successfully', $ans)` @param mathematical expression @return $this
evaluate Evaluate PHP expressions eg:beforeQuering()->evaluate("\DB::table('users')->get()")->storeAs($output)->stopAndOutput(1001, 'got users successfully', $output) @param $expression @return $this
sumUp find the sum of numbers. eg: `->beforeQuerying()->sumUp(3,4,5,6,7)->storeAs($ans)->stopAndOutput(1001,'got answer successfully', $ans)` @param integer $num @return $this
subtract subtract a bunch of numbers. eg: `->beforeQuerying()->subtract(3,4,5,6,7)->storeAs($ans)->stopAndOutput(1001,'got answer successfully', $ans)` also `->beforeQuerying()->from(5)->subtract(3)->storeAs($ans)->stopAndOutput(1001,'got answer successfully', $ans)` @return $this
multiply find the product of numbers .eg: `->beforeQuerying()->multiply(3,4,5,6,7)->storeAs($ans)->stopAndOutput(1001,'got answer successfully', $ans)` @return $this
divide divide a range of numbers.eg: `->beforeQuerying()->divide(6,2)->storeAs($ans)->stopAndOutput(1001,'got answer successfully', $ans)` @return $this
divideBy This picks results from your earlier computation and divides it by a given number. eg: `->beforeQuerying()->sumUp(3,4,5,6,7)->divdeBy(6)->storeAs($ans)->stopAndOutput(1001,'got answer successfully', $ans)` @param $number @return $this
findSquareRootOf Find the square root of a number. eg:`->beforeQuerying()->findSquareRoot($number)->storeAs($input_root)` @param integer $num @return $this
getSquareRoot Get the squareRoot of the result of the preceeding computation eg: `->beforeQuerying()->divide(20, 40)->getSquareRoot()->storeAs($output)->succeedWith($output)` return $this
roundUp round up a number. eg: `->beforeCreating()->roundUp($input_milage, 1)->storeAs($input_milage)` @param integer $number @param integer $precision @return $this
percentOf Find the percent of a number eg: `->beforeQuerying()->find(10)->percentOf(200)->storeAs($input_discount)` @param $number @return $this
concatenate Concatenate strings together eg: `->beforeCreating()->concatenate("user_",$input_name)` @param n number of params @return $this
getFirstCharacter Get first character eg: `->beforeCreating()->getFirstCharacter("Hello")->storeAs($first_char)->succeedWith($first_char)` @param $string @return $this
getSecondCharacter Get second character eg: `->beforeCreating()->getSecondCharacter("Hello")->storeAs($second_char)->succeedWith($second_char)` @param $string @return $this
getThirdCharacter Get third character eg: `->beforeCreating()->getThirdCharacter("Hello")->storeAs($third_char)->succeedWith($third_char)` @param $string @return $this
getLastCharacter Get last character character eg: `->beforeCreating()->getLastCharacter("Hello")->storeAs($last_char)->succeedWith($last_char)` @param $string @return $this
getLastButOneCharacter Get last but one character eg: `->beforeCreating()->getLastButOneCharacter("Hello")->storeAs($last_but_one_char)->succeedWith($last_but_one_char)` @param $string @return $this
reverseString Reverse a string eg: ->beforeQuerying()->assign("nan")->to($string)->reverseString()->storeAs($reverseString) ->whenever(assertIts::equal($string, $reverseString))->succeedWith("Its a palindrome :)") ->otherwise()->failWith("Its not a palindrome :(") @param $string @return $this
findNReplace replace a string with another eg `->beforeCreating()->findNReplace("{{name}}", $input_name, $input_message)->storeAs($input_message)` @param $string @param $replacement @param $subject @return $this
convertToUpperCase change string to uppercase eg: `->beforeCreating()->convertToUpperCase($input_name)->storeAs($input_name)` @param $string @return $this
convertToLowerCase change string to lowercase eg: `->beforeCreating()->convertToLowerCase($input_name)->storeAs($input_name)` @param $string @return $this
truncateString Truncate a string to some length eg `->beforeCreating()->truncateString(4, $input_desc)->getResults($trucatedString)->storeAs($stub)` @param $len @param $string @param $trimMaker @return $this
countWords Count the number of words in a sentence eg: `->beforeCreating()->onTable('users')->countWords($input_description)->storeAs($desc_length)->whenever($desc_length <= 5)->failWith("Your product description is very short")` @param $sentence @return $this
countCharacters Find the number of characters in a word or sentence eg: `->beforeCreating()->onTable('users')->countCharacters($input_name)->storeAs($name_length)->whenever($name_length <= 0)->failWith("name seems to be empty")` @param word @return $this
getTimestamp The `getTimestamp` method returns the current timestamp. eg: beforeQuerying()->getTimestamp()->storeAs($timestamp)->succeedWith($timestamp) @return $this
getCurrentYear Get the current year using the `getCurrentYear` method eg:beforeQuering()->getCurrentYear()->storeAs($currentYear)succeedWith($currentYear) @return $this
getCurrentMonth Get the current month using the `getCurrentMonth` method eg:beforeQuering()->getCurrentMonth()->storeAs($currentMonth)->succeedWith($currentMonth) @return $this
getCurrentDay Get the current day using the `getCurrentDay` method eg:beforeQuering()->getCurrentDay()->storeAs($currentDay)->succeedWith($currentDay) @return $this
getCurrentHour Get the current hour using the `getCurrentHour` method eg:beforeQuering()->getCurrentHour()->storeAs($currentHour)->succeedWith($currentHour) @return $this
getFormattedDate Get the current second using the `getFormattedDate` method eg: beforeQuering()->getFormattedDate()->storeAs($formattedDate)->succeedWith($formattedDate) @return $this
generateRandomInteger generates random integers. This may be used for invitation or promotional code generation. eg `->beforeCreating()->generateRandomInteger(10)->storeAs($promo_code)->assign($promo_code)->to($input_promo)` @param $length @return $this
generateRandomAlphanums generates random alphanumeric values. This may be used for generating order Ids. eg `->beforeCreating()->generateRandomAlphanums()->storeAs($order_id)->assign($order_id)->to($input_order_id)` @return $this
generateRandomString generates random string.This generates random string codes. eg `->beforeCreating()->generateRandomInteger(10)->storeAs($promo_code)->assign($promo_code)->to($input_promo)` @param $length @return $this
generateUniqueId generates unique Id.This generates unique Id . eg `->beforeCreating()->generateUniqueId()->storeAs($user_id)->assign($user_id)->to($input_id)` @param $length @return $this ",
mutateStatusCode mutate response status code. This will change the status code that is being outputed eg: `->afterQuering()->mutateStatusCode(1111)`. NB: you should only change the status code if you know what you doing. Changing it might cause some of the official SDKs to malfunction. @param $newCode @return $this
mutateResponseMessage mutate response message. This will change the Message within the response body sent back to the client. eg ->afterQuering()->mutateResponseMessage("new response message") @param $newMessage @return $this
mutateResponsePayload mutate response payload. This will Replace the Response payload being sent back to the client eg: ->afterQuering()->mutateResponsePayload(["name"=>"Edmond"]) @param $newPayload @return $this