-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from aidsoul/release/v.1.4
Closing Release/v.1.4
- Loading branch information
Showing
45 changed files
with
499 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,11 @@ | |
|
||
use Vktote\Config\Config; | ||
use Vktote\Telegram\Telegram; | ||
use Vktote\Wall\Wall; | ||
use Vktote\Vk\Wall\Wall; | ||
|
||
/** | ||
* Start parsing and sending data | ||
* Entry point in programm | ||
* | ||
* @author aidsoul <[email protected]> | ||
* @license MIT | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
* @author aidsoul <[email protected]> | ||
* @license MIT | ||
*/ | ||
abstract class Config | ||
abstract class Config implements ConfigInterface | ||
{ | ||
/** | ||
* | ||
|
@@ -24,7 +24,7 @@ abstract class Config | |
*/ | ||
public static function set(string $сonfigPath): void | ||
{ | ||
self::$config = parse_ini_file($сonfigPath, true); | ||
self::$config = parse_ini_file($сonfigPath, true); | ||
} | ||
|
||
/** | ||
|
@@ -49,34 +49,38 @@ public function __get(string $property) | |
$className = (new \ReflectionClass($this))->getShortName(); | ||
if (!empty($property)) { | ||
if ( | ||
array_key_exists($className, self::$config) and | ||
property_exists($this, $property) and | ||
array_key_exists( | ||
$property, | ||
self::$config[$className] | ||
) | ||
array_key_exists($className, self::$config) and | ||
property_exists($this, $property) and | ||
array_key_exists( | ||
$property, | ||
self::$config[$className] | ||
) | ||
) { | ||
$item = self::$config[$className][$property]; | ||
if (!empty($item)) { | ||
$this->$property = $item; | ||
if ( | ||
!method_exists($this, $property) or | ||
method_exists($this, $property) and | ||
$this->$property() === true | ||
!method_exists($this, $property) or | ||
method_exists($this, $property) and | ||
$this->$property() === true | ||
) { | ||
$this->$property = $item; | ||
return $this->$property; | ||
} | ||
} else { | ||
} | ||
else { | ||
Message::find()->show(false, __TRAIT__, 'propertyNullItem', "[{$className}->[{$property}=>'...']"); | ||
} | ||
} else { | ||
} | ||
else { | ||
Message::find()->show(false, __TRAIT__, 'property', "[{$className}]->{$property}=>'?'"); | ||
} | ||
} else { | ||
} | ||
else { | ||
Message::find()->show(false, __TRAIT__, 'propertyNull', "[{$className}->[{$property}=>'...']"); | ||
} | ||
} catch (\Exception $e) { | ||
} | ||
catch (\Exception $e) { | ||
throw new \Exception($e); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,15 @@ | |
|
||
/** | ||
* Config interface | ||
* | ||
* @license MIT | ||
* @author aidsoul <[email protected]> | ||
*/ | ||
interface ConfigInterface | ||
{ | ||
/** | ||
* @param string $property | ||
* @return void | ||
*/ | ||
public function __get(string $property); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,13 @@ | |
|
||
namespace Vktote\Config; | ||
|
||
use Vktote\Config\ConfigInterface; | ||
|
||
/** | ||
* Db class | ||
* | ||
* @author aidsoul <[email protected]> | ||
* @license MIT | ||
*/ | ||
class Db extends Config implements ConfigInterface | ||
class Db extends Config | ||
{ | ||
/** | ||
* @var string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,13 @@ | |
|
||
namespace Vktote\Config; | ||
|
||
use Vktote\Config\ConfigInterface; | ||
|
||
/** | ||
* Telegram class | ||
* | ||
* @author aidsoul <[email protected]> | ||
* @license MIT | ||
*/ | ||
class Telegram extends Config implements ConfigInterface | ||
class Telegram extends Config | ||
{ | ||
/** | ||
* @var string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,16 @@ | |
|
||
namespace Vktote\Config; | ||
|
||
use Vktote\Config\ConfigInterface; | ||
|
||
class User extends Config implements ConfigInterface | ||
/** | ||
* Class of User | ||
* | ||
* @author aidsoul [email protected] | ||
* @license MIT | ||
*/ | ||
class User extends Config | ||
{ | ||
/** | ||
* Summary of password | ||
* @var string | ||
*/ | ||
protected string $password; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
namespace Vktote\Config; | ||
|
||
use Vktote\Config\ConfigInterface; | ||
use Vktote\Message\Message; | ||
|
||
/** | ||
|
@@ -11,7 +10,7 @@ | |
* @author aidsoul <[email protected]> | ||
* @license MIT | ||
*/ | ||
class Vk extends Config implements ConfigInterface | ||
class Vk extends Config | ||
{ | ||
/** | ||
* @var string | ||
|
@@ -35,10 +34,10 @@ class Vk extends Config implements ConfigInterface | |
*/ | ||
protected function count(): bool | ||
{ | ||
if (isset($this->count) and $this->count > 100) { | ||
Message::find()->show(false, __CLASS__, 'count'); | ||
} else { | ||
return true; | ||
} | ||
if (isset($this->count) and $this->count > 100) { | ||
Message::find()->show(false, __CLASS__, 'count'); | ||
} else { | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,17 +10,17 @@ | |
* @author aidsoul <[email protected]> | ||
* @license MIT | ||
*/ | ||
class Post extends Database implements PostInterface | ||
class PostModel extends Database implements PostInterface | ||
{ | ||
/** | ||
* @param string $tableName | ||
* @param string $idPost | ||
* @param string $groupId | ||
*/ | ||
public function __construct( | ||
private readonly string $tableName = 'post', | ||
private readonly string $idPost = 'id_post', | ||
private readonly string $groupId = 'group_id' | ||
private string $tableName = 'post', | ||
private string $idPost = 'id_post', | ||
private string $groupId = 'group_id' | ||
) { | ||
parent::__construct(); | ||
} | ||
|
@@ -47,7 +47,8 @@ public function create(int $postId, int $groupId): void | |
* | ||
* @param integer $postId | ||
* @param integer $groupId | ||
* @return integer | ||
* | ||
* @return int|bool | ||
*/ | ||
public function check(int $postId, int $groupId): int|bool | ||
{ | ||
|
@@ -62,4 +63,24 @@ public function check(int $postId, int $groupId): int|bool | |
|
||
return $ask ? $ask[$this->idPost] : false; | ||
} | ||
|
||
/** | ||
* Get last post | ||
* | ||
* @param integer $groupId | ||
* | ||
* @return int | ||
*/ | ||
public function getLastPost(string $groupName): int | ||
{ | ||
$ask = self::$pdo | ||
->select(['MAX(' . $this->idPost . ') as max']) | ||
->from($this->tableName) | ||
->leftJoin('vkgroup')->on('group_id', 'id_group') | ||
->where('name', '=', $groupName) | ||
->execute() | ||
->fetch(); | ||
|
||
return empty($ask['max']) ? 0 : $ask['max']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,24 +10,25 @@ | |
* @author aidsoul <[email protected]> | ||
* @license MIT | ||
*/ | ||
class Vkgroup extends Database implements VkgroupInterface | ||
class VkgroupModel extends Database implements VkgroupInterface | ||
{ | ||
/** | ||
* @param string $tableName | ||
* @param string $idGroup | ||
* @param string $name | ||
*/ | ||
public function __construct( | ||
private readonly string $tableName = 'vkgroup', | ||
private readonly string $idGroup = 'id_group', | ||
private readonly string $name = 'name' | ||
private string $tableName = 'vkgroup', | ||
private string $idGroup = 'id_group', | ||
private string $name = 'name' | ||
|
||
) { | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* @param string $nameGroup | ||
* | ||
* @return void | ||
*/ | ||
public function create(string $nameGroup): void | ||
|
@@ -41,6 +42,7 @@ public function create(string $nameGroup): void | |
|
||
/** | ||
* @param string $nameGroup | ||
* | ||
* @return integer|boolean | ||
*/ | ||
public function check(string $nameGroup): int|bool | ||
|
@@ -58,6 +60,7 @@ public function check(string $nameGroup): int|bool | |
|
||
/** | ||
* @param integer|string $idGroup | ||
* | ||
* @return void | ||
*/ | ||
public function remove(int|string $idGroup): void | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace Vktote\File; | ||
namespace Vktote\Settings\File; | ||
|
||
/** | ||
* File class | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.