Skip to content

Commit

Permalink
Merge pull request #3 from paragraf-lex/analysis-8w1gZE
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
paragraf-lex authored Jan 10, 2019
2 parents dd6e45c + 13cba29 commit 1998c86
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
11 changes: 5 additions & 6 deletions src/Bot.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
use Paragraf\ViberBot\Http\Http;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;

//TODO: Make it through composer | Not it's not working, no reason
require_once "helpers.php";
require_once 'helpers.php';

class Bot
{
Expand Down Expand Up @@ -56,13 +57,11 @@ public function hears($text)

if (is_string($text)) {

/**
/*
* This represent regex.
*/
if (startWith('/', $text) && endWith('/', $text))
{
if (preg_match($text, $this->request->message['text']))
{
if (startWith('/', $text) && endWith('/', $text)) {
if (preg_match($text, $this->request->message['text'])) {
return $this;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/ViberBotController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function index(Request $request)
(new Bot($request, new TextMessage()))
->on(new MessageEvent($request->timestamp, $request->message_token, new ViberUser($request->sender['id'], $request->sender['name']), $request->message))
->hears('/^[\\\P\\\p][\d+]{5,5}$/')
->body(function (){
->body(function () {
dump(factory(User::class)->create()->id);
dump(factory(User::class)->create()->id);
})
Expand Down
13 changes: 5 additions & 8 deletions src/helpers.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
<?php


if (!function_exists('startWith')) {

if (! function_exists('startWith')) {
function startWith($needle, $haystack)
{
$length = strlen($needle);
return (substr($haystack, 0, $length) === $needle);
}

return substr($haystack, 0, $length) === $needle;
}
}

if (!function_exists('endWith')) {

if (! function_exists('endWith')) {
function endWith($needle, $haystack)
{
$length = strlen($needle);
if ($length == 0) {
return true;
}

return (substr($haystack, -$length) === $needle);
return substr($haystack, -$length) === $needle;
}

}

0 comments on commit 1998c86

Please sign in to comment.