Commit 28157a46 authored by MBoretto's avatar MBoretto

CONTRIBUTING and DB.php

parent 970ae10b
...@@ -28,6 +28,18 @@ Further code convention adopted ...@@ -28,6 +28,18 @@ Further code convention adopted
------------------------------- -------------------------------
- Each method and class is documented with a docblock - Each method and class is documented with a docblock
Example for a function or methods:
```
/**
* Get formatted date
*
* @param string $location
*
* @return string
*/
```
- Each file is provided with the following header: - Each file is provided with the following header:
``` ```
/* /*
......
<?php <?php
/* /**
* This file is part of the TelegramBot package. * This file is part of the TelegramBot package.
* *
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com> * (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
...@@ -26,6 +26,9 @@ use Longman\TelegramBot\Exception\TelegramException; ...@@ -26,6 +26,9 @@ use Longman\TelegramBot\Exception\TelegramException;
* @link http://www.github.com/akalongman/php-telegram-bot * @link http://www.github.com/akalongman/php-telegram-bot
*/ */
/**
* Class DB.
*/
class DB class DB
{ {
/** /**
...@@ -62,6 +65,7 @@ class DB ...@@ -62,6 +65,7 @@ class DB
* @param array $credentials Database connection details * @param array $credentials Database connection details
* @param Telegram $telegram Telegram object to connect with this object * @param Telegram $telegram Telegram object to connect with this object
* @param string $table_prefix Table prefix * @param string $table_prefix Table prefix
*
* @return PDO PDO database object * @return PDO PDO database object
*/ */
public static function initialize(array $credentials, Telegram $telegram, $table_prefix = null) public static function initialize(array $credentials, Telegram $telegram, $table_prefix = null)
...@@ -129,6 +133,7 @@ class DB ...@@ -129,6 +133,7 @@ class DB
* Fetch update(s) from DB * Fetch update(s) from DB
* *
* @param int $limit Limit the number of updates to fetch * @param int $limit Limit the number of updates to fetch
*
* @return array|bool Fetched data or false if not connected * @return array|bool Fetched data or false if not connected
*/ */
public static function selectTelegramUpdate($limit = null) public static function selectTelegramUpdate($limit = null)
...@@ -161,6 +166,7 @@ class DB ...@@ -161,6 +166,7 @@ class DB
* Fetch message(s) from DB * Fetch message(s) from DB
* *
* @param int $limit Limit the number of messages to fetch * @param int $limit Limit the number of messages to fetch
*
* @return array|bool Fetched data or false if not connected * @return array|bool Fetched data or false if not connected
*/ */
public static function selectMessages($limit = null) public static function selectMessages($limit = null)
...@@ -195,6 +201,7 @@ class DB ...@@ -195,6 +201,7 @@ class DB
* Convert from unix timestamp to timestamp * Convert from unix timestamp to timestamp
* *
* @param int $time Unix timestamp * @param int $time Unix timestamp
*
* @return null|string Timestamp if a time has been passed, else null * @return null|string Timestamp if a time has been passed, else null
*/ */
protected static function getTimestamp($time = null) protected static function getTimestamp($time = null)
...@@ -214,6 +221,7 @@ class DB ...@@ -214,6 +221,7 @@ class DB
* @param int $message_id * @param int $message_id
* @param int $inline_query_id * @param int $inline_query_id
* @param int $chosen_inline_query_id * @param int $chosen_inline_query_id
*
* @return bool|null * @return bool|null
*/ */
public static function insertTelegramUpdate($id, $message_id, $inline_query_id, $chosen_inline_query_id) public static function insertTelegramUpdate($id, $message_id, $inline_query_id, $chosen_inline_query_id)
...@@ -257,6 +265,7 @@ class DB ...@@ -257,6 +265,7 @@ class DB
* @param Entities\User $user * @param Entities\User $user
* @param string $date * @param string $date
* @param Entities\Chat $chat * @param Entities\Chat $chat
*
* @return bool|null * @return bool|null
*/ */
public static function insertUser(User $user, $date, Chat $chat = null) public static function insertUser(User $user, $date, Chat $chat = null)
...@@ -322,6 +331,7 @@ class DB ...@@ -322,6 +331,7 @@ class DB
* Insert request into database * Insert request into database
* *
* @param Entities\Update &$update * @param Entities\Update &$update
*
* @return bool * @return bool
*/ */
public static function insertRequest(Update &$update) public static function insertRequest(Update &$update)
...@@ -388,6 +398,7 @@ class DB ...@@ -388,6 +398,7 @@ class DB
* @todo No return value at the end. Just return true? * @todo No return value at the end. Just return true?
* *
* @param Entities\InlineQuery &$inline_query * @param Entities\InlineQuery &$inline_query
*
* @return bool * @return bool
*/ */
public static function insertInlineQueryRequest(InlineQuery &$inline_query) public static function insertInlineQueryRequest(InlineQuery &$inline_query)
...@@ -436,6 +447,7 @@ class DB ...@@ -436,6 +447,7 @@ class DB
* Insert Message request in db * Insert Message request in db
* *
* @param Entities\Message &$message * @param Entities\Message &$message
*
* @return bool If the insert was successful * @return bool If the insert was successful
*/ */
public static function insertMessageRequest(Message &$message) public static function insertMessageRequest(Message &$message)
...@@ -632,6 +644,7 @@ class DB ...@@ -632,6 +644,7 @@ class DB
* @param bool $select_users * @param bool $select_users
* @param string $date_from * @param string $date_from
* @param string $date_to * @param string $date_to
*
* @return array|bool Selected chats or false if invalid arguments * @return array|bool Selected chats or false if invalid arguments
*/ */
public static function selectChats( public static function selectChats(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment