diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml index bd93b20..debf364 100644 --- a/.github/workflows/analyze.yml +++ b/.github/workflows/analyze.yml @@ -39,7 +39,7 @@ jobs: with: php-version: ${{ matrix.php-versions }} tools: composer, pecl, phpunit - extensions: intl, json, mbstring, mysqlnd, xdebug, xml, sqlite3 + extensions: intl, json, mbstring, gd, mysqlnd, xdebug, xml, sqlite3 - name: Get composer cache directory id: composer-cache diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a1cb9a3..9ded22a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,7 @@ jobs: with: php-version: ${{ matrix.php-versions }} tools: composer, pecl, phpunit - extensions: intl, json, mbstring, mysqlnd, xdebug, xml, sqlite3 + extensions: intl, json, mbstring, gd, mysqlnd, xdebug, xml, sqlite3 coverage: xdebug - name: Get composer cache directory diff --git a/README.md b/README.md index 898ea46..7a2616e 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ to ensure the database is setup correctly: ## Configuration (optional) The library's default behavior can be altered by extending its config file. Copy -**bin/Visits.php** to **app/Config/** and follow the instructions in the +**examples/Visits.php** to **app/Config/** and follow the instructions in the comments. If no config file is found in app/Config the library will use its own. ## Usage diff --git a/composer.json b/composer.json index f978713..625635d 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ }, "require-dev": { "codeigniter4/codeigniter4": "dev-develop", - "tatter/tools": "^1.6" + "tatter/tools": "^1.7" }, "autoload": { "psr-4": { diff --git a/bin/Visits.php b/examples/Visits.php similarity index 100% rename from bin/Visits.php rename to examples/Visits.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index dfa6a85..b1385f6 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -13,7 +13,6 @@ parameters: - '#Access to protected property .+\\[A-Za-z]+Model::\$[A-Za-z]+#' - '#Access to an undefined property CodeIgniter\\Session\\Session::\$session_id#' - '#Call to an undefined static method Config\\Services::[A-Za-z]+\(\)#' - - '#Unsafe usage of new static\(\)*#' universalObjectCratesClasses: - CodeIgniter\Entity - Faker\Generator diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 01f689c..745249c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -36,6 +36,10 @@ + + + + diff --git a/src/Database/Migrations/20190319121802_create_table_visits.php b/src/Database/Migrations/20190319121802_create_table_visits.php index f7ce5d6..8e820f4 100644 --- a/src/Database/Migrations/20190319121802_create_table_visits.php +++ b/src/Database/Migrations/20190319121802_create_table_visits.php @@ -7,21 +7,21 @@ class Migration_create_table_visits extends Migration public function up() { $fields = [ - 'session_id' => ['type' => 'VARCHAR', 'constraint' => 32], - 'user_id' => ['type' => 'INT', 'null' => true], - 'ip_address' => ['type' => 'BIGINT', 'null' => true], - 'user_agent' => ['type' => 'VARCHAR', 'constraint' => 255], - 'scheme' => ['type' => 'VARCHAR', 'constraint' => 15], - 'host' => ['type' => 'VARCHAR', 'constraint' => 63], - 'port' => ['type' => 'VARCHAR', 'constraint' => 15], - 'user' => ['type' => 'VARCHAR', 'constraint' => 31], - 'pass' => ['type' => 'VARCHAR', 'constraint' => 255], - 'path' => ['type' => 'VARCHAR', 'constraint' => 255], - 'query' => ['type' => 'VARCHAR', 'constraint' => 255], - 'fragment' => ['type' => 'VARCHAR', 'constraint' => 31], - 'views' => ['type' => 'INT', 'default' => 1], - 'created_at' => ['type' => 'DATETIME', 'null' => true], - 'updated_at' => ['type' => 'DATETIME', 'null' => true], + 'session_id' => ['type' => 'varchar', 'constraint' => 32, 'default' => ''], + 'user_id' => ['type' => 'int', 'null' => true], + 'ip_address' => ['type' => 'bigint', 'null' => true], + 'user_agent' => ['type' => 'varchar', 'constraint' => 255, 'default' => ''], + 'scheme' => ['type' => 'varchar', 'constraint' => 15, 'default' => ''], + 'host' => ['type' => 'varchar', 'constraint' => 63], + 'port' => ['type' => 'varchar', 'constraint' => 15, 'default' => ''], + 'user' => ['type' => 'varchar', 'constraint' => 31, 'default' => ''], + 'pass' => ['type' => 'varchar', 'constraint' => 255, 'default' => ''], + 'path' => ['type' => 'varchar', 'constraint' => 255], + 'query' => ['type' => 'varchar', 'constraint' => 255, 'default' => ''], + 'fragment' => ['type' => 'varchar', 'constraint' => 31, 'default' => ''], + 'views' => ['type' => 'int', 'default' => 1], + 'created_at' => ['type' => 'datetime', 'null' => true], + 'updated_at' => ['type' => 'datetime', 'null' => true], ]; $this->forge->addField('id'); diff --git a/src/Models/VisitModel.php b/src/Models/VisitModel.php index d887f46..0090a44 100644 --- a/src/Models/VisitModel.php +++ b/src/Models/VisitModel.php @@ -6,9 +6,11 @@ class VisitModel extends Model { protected $table = 'visits'; protected $primaryKey = 'id'; + protected $returnType = 'Tatter\Visits\Entities\Visit'; - protected $returnType = 'Tatter\Visits\Entities\Visit'; + protected $useTimestamps = true; protected $useSoftDeletes = false; + protected $skipValidation = false; protected $allowedFields = [ 'session_id', @@ -26,13 +28,8 @@ class VisitModel extends Model 'fragment', ]; - protected $useTimestamps = true; - - protected $validationRules = [ + protected $validationRules = [ 'host' => 'required', 'path' => 'required', ]; - protected $validationMessages = []; - protected $skipValidation = false; - }