Erasin 4 years ago
commit
5dbb4b5b62
12 changed files with 395 additions and 0 deletions
  1. 3 0
      .gitignore
  2. 18 0
      composer.json
  3. 16 0
      src/Dy/Crypt.php
  4. 18 0
      src/Dy/Fenci.php
  5. 72 0
      src/Dy/Image.php
  6. 13 0
      src/Dy/Log.php
  7. 78 0
      src/Dy/Map.php
  8. 40 0
      src/Dy/Otp.php
  9. 39 0
      src/Dy/Rand.php
  10. 18 0
      src/Dy/Shell.php
  11. 24 0
      src/Dy/Strings.php
  12. 56 0
      src/Dy/Time.php

+ 3 - 0
.gitignore

@@ -0,0 +1,3 @@
+php_errors.log
+test
+.env

+ 18 - 0
composer.json

@@ -0,0 +1,18 @@
+{
+    "name": "dyutils/ide-stubs",
+    "type": "library",
+    "authors": [
+        {
+            "name": "Erasin",
+            "email": "erasinoo@gmail.com"
+        }
+    ],
+    "require": {
+        "php": ">=7.2.0"
+    },
+    "autoload-dev": {
+        "psr-4": {
+            "Dy\\": "src/"
+        }
+    }
+}

+ 16 - 0
src/Dy/Crypt.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace Dy;
+
+class Crypt
+{
+    /**
+     * md5
+     *
+     * @param string $str
+     * @return string
+     */
+    public static function md5(string $str)
+    {
+    }
+}

+ 18 - 0
src/Dy/Fenci.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace Dy;
+
+class Fenci
+{
+    /**
+     * 分词处理
+     *
+     * @param string $str
+     * @param bool $hmm  使用 hmm 参数
+     *
+     * @return array|ErrorException
+     */
+    public function do(string $str, bool $hmm = false)
+    {
+    }
+}

+ 72 - 0
src/Dy/Image.php

@@ -0,0 +1,72 @@
+<?php
+
+namespace Dy;
+
+class Fenci
+{
+    /**
+     * 尺寸缩放
+     *
+     * @param string $src
+     * @param string $dest
+     * @param integer $width
+     * @param integer $height
+     * @return void|ErrorException
+     */
+    public function resize(string $src, string $dest, int $width, int $height)
+    {
+    }
+
+    /**
+     * 截图
+     *
+     * @param string $src
+     * @param string $dest
+     * @param integer $x
+     * @param integer $y
+     * @param integer $width
+     * @param integer $height
+     * @return void|ErrorException
+     */
+    public function crop(string $src, string $dest, int $x, int $y, int $width, int $height)
+    {
+    }
+
+    // public function water(string $src1, string $src2, string $dest, int $x, int $y, int $width, int $height) { }
+
+    /**
+     * 验证码
+     *
+     * @param string $dest
+     * @param integer $width
+     * @param integer $height
+     * @return void|array|ErrorException
+     */
+    public function captcha(string $dest, int $width, int $height)
+    {
+    }
+
+    /**
+     * QR 生成
+     *
+     * @param string $content
+     * @param string $dest
+     * @param integer $width
+     * @return void|bool|ErrorException
+     */
+    public function qr(string $content, string $dest, int $width)
+    {
+    }
+
+    /**
+     * 头像生成
+     *
+     * @param string $dest
+     * @param integer $width
+     * @param integer $padding
+     * @return void|bool|ErrorException
+     */
+    public function avatar(string $dest, int $width = 128, int $padding = 5)
+    {
+    }
+}

+ 13 - 0
src/Dy/Log.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace Dy;
+
+class Log
+{
+    /**
+     * 新建分词分析器
+     */
+    public function __construct()
+    {
+    }
+}

+ 78 - 0
src/Dy/Map.php

@@ -0,0 +1,78 @@
+<?php
+
+namespace Dy;
+
+class Map
+{
+    /**
+     * 纬度
+     *
+     * @var float
+     */
+    public $lng;
+
+    /**
+     * 经度
+     *
+     * @var float
+     */
+    public $lat;
+
+    /**
+     * 模式
+     *
+     * 0. bd09
+     * 1. wgs84
+     * 2. gcj02
+     * @var int
+     */
+    public $mode;
+
+    /**
+     * 新建座标
+     *
+     * @param float $lng 纬度
+     * @param float $lat 经度
+     * @param integer $mode 模式
+     */
+    public function __construct(float $lng, float $lat, int $mode)
+    {
+    }
+
+    /**
+     * 转换为 bd09 座标系
+     *
+     * @return Map
+     */
+    public function bd09()
+    {
+    }
+
+    /**
+     * 转换为 gcj02 座标系
+     *
+     * @return Map
+     */
+    public function gcj02()
+    {
+    }
+
+    /**
+     * 转换为 wgs84 座标系
+     *
+     * @return Map
+     */
+    public function wgs84()
+    {
+    }
+
+    /**
+     * 长度计算
+     *
+     * @param Map $other
+     * @return float
+     */
+    public function distance(Map $other)
+    {
+    }
+}

+ 40 - 0
src/Dy/Otp.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace Dy;
+
+class Otp
+{
+    /**
+     * 新建生成器
+     *
+     * @param string $secret 密钥
+     * @param int $digits  长度
+     * @param int $preiod  变动间隔 htop时候有效 建议60
+     *
+     * @return void
+     */
+    public function __construct(string $secret, int $digits, int $preiod)
+    {
+    }
+
+    /**
+     * 顺序验证码
+     *
+     * @package int $index  序号
+     *
+     * @return integer
+     */
+    public function hotp(int $index)
+    {
+    }
+
+    /**
+     * 时序验证码
+     *
+     * @return integer
+     */
+    public function totp()
+    {
+        // code...
+    }
+}

+ 39 - 0
src/Dy/Rand.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace Dy;
+
+/**
+ * 随机数
+ */
+class Rand
+{
+    /**
+     * 随机浮点值
+     *
+     * @return void
+     */
+    public static function float()
+    {
+    }
+
+    /**
+     * 随机字符串
+     * 包含字符和数字
+     *
+     * @param integer $limit 字符串长度
+     * @return void
+     */
+    public static function alphanumeric(int $limit)
+    {
+    }
+
+    /**
+     * 随机数字
+     *
+     * @param integer $limit 数字长度
+     * @return void
+     */
+    public static function numeric(int $limit)
+    {
+    }
+}

+ 18 - 0
src/Dy/Shell.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace Dy;
+
+class Shell
+{
+    /**
+     * shell
+     *
+     * @param string $cmd 命令
+     * @param string $str 参数
+     *
+     * @return bool
+     */
+    public static function exec(string $cmd, string $flags)
+    {
+    }
+}

+ 24 - 0
src/Dy/Strings.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace Dy;
+
+/**
+ * 处理
+ */
+class Strings
+{
+    /**
+     * 汉字转拼音
+     *
+     * @param string $str 汉字
+     * @return array 拼音
+     */
+    public static function pinyin(string $str)
+    {
+    }
+
+    // TODO
+    public static function strcut(string $str, $start, $end)
+    {
+    }
+}

+ 56 - 0
src/Dy/Time.php

@@ -0,0 +1,56 @@
+<?php
+
+namespace Dy;
+
+class Time
+{
+    /**
+     * 返回当前时间字符串
+     *
+     * @param boolean $is_local 是否为本地时间,默认 UTC时间
+     * @return string 时间字符串
+     */
+    public static function now_time(bool $is_local = true)
+    {
+    }
+
+    /**
+     * 返回当前时间戳
+     *
+     * @param boolean $is_local 是否为本地时间,默认 UTC时间
+     * @return integer 时间戳
+     */
+    public static function now(bool $is_local = true)
+    {
+    }
+
+    /**
+     * 返回当前秒时间戳 1/10^3
+     *
+     * @param boolean $is_local 是否为本地时间,默认 UTC时间
+     * @return integer 时间戳
+     */
+    public static function now_millis(bool $is_local = true)
+    {
+    }
+
+    /**
+     * 返回当前时间秒时间戳 1/10^6
+     *
+     * @param boolean $is_local 是否为本地时间,默认 UTC时间
+     * @return integer 时间戳
+     */
+    public static function now_micro(bool $is_local = true)
+    {
+    }
+
+    /**
+     * 返回当前时间纳秒时间戳 1/10^9
+     *
+     * @param boolean $is_local 是否为本地时间,默认 UTC时间
+     * @return integer 时间戳
+     */
+    public static function now_nano(bool $is_local = true)
+    {
+    }
+}