diff --git a/README.md b/README.md index ac3c37b..ba9c63d 100644 --- a/README.md +++ b/README.md @@ -1876,7 +1876,9 @@ In a nutshell: > Every minor version means that it adds a new functionality i.e. 1.5 -> 1.6 (new methods) > > Every decimal version means that it patches/fixes/refactoring a previous functionality i.e. 1.5.0 -> 1.5.1 (fix) - +* 4.9 2024-08-02 + * [update] camelize update to consider "-" and "\_" and not only "\_" + * [update] update dependencies. * 4.8 2024-07-06 * [upd] added fetchMode for runRawQuery() * [new] added setFetchMode() diff --git a/composer.json b/composer.json index 2885396..42b0466 100644 --- a/composer.json +++ b/composer.json @@ -31,10 +31,10 @@ "require": { "php": ">=7.4", "ext-json": "*", - "eftec/clione": "^1.32", + "eftec/clione": "^1.33", "ext-pdo": "*", "ext-readline": "*", - "eftec/messagecontainer": "^2.8" + "eftec/messagecontainer": "^2.9" }, "bin": [ "lib/pdoonecli" diff --git a/lib/IPdoOneCache.php b/lib/IPdoOneCache.php index 9f7335b..4c22299 100644 --- a/lib/IPdoOneCache.php +++ b/lib/IPdoOneCache.php @@ -1,5 +1,5 @@ -[1=>1]],this('select 1',null,true) */ public function runRawQuery(string $rawSql, ?array $params = null, ?bool $returnArray = true, bool $useCache = false, $cacheFamily = null, int $fetchMode = PDO::FETCH_ASSOC, $fetchArgument = null) @@ -2525,9 +2524,21 @@ private function typeDict($row) return $this->service->typeDict($row); } - public static function camelize($input, $separator = '_') + /** + * It transform a string into a camel case format
+ * **Example:** + * ``` + * $value=PdoOne::camelize('camel_format'); //CamelFormat + * $value=PdoOne::camelize('camel-format'); //CamelFormat + * ``` + * + * @param string $input + * @param string $separator (optional) + * @return array|string|string[] + */ + public static function camelize(string $input,string $separator = '_-') { - return str_replace($separator, '', ucwords($input, $separator)); + return str_replace(str_split($separator), '', ucwords($input, $separator)); } public static function varExport($input, $indent = "\t"): ?string @@ -2838,9 +2849,11 @@ public function getDefIdentities(string $table): array /** * It sets a value into the query (insert or update)
* **Example:** - * ->from("table")->set('field1=?',20),set('field2=?','hello')->insert()
- * ->from("table")->set("type=?",[6])->where("i=1")->update()
- * set("type=?",6) // automatic
+ * ``` + * $this->from("table")->set('field1=?',20),set('field2=?','hello')->insert(); + * $this->from("table")->set("type=?",[6])->where("i=1")->update(); + * $this->>set("type=?",6); // automatic + * ``` * * @param string|array $sqlOrArray * @param array|mixed $param diff --git a/tests/PdoOne_mysql_Test.php b/tests/PdoOne_mysql_Test.php index ce46418..6e6933a 100644 --- a/tests/PdoOne_mysql_Test.php +++ b/tests/PdoOne_mysql_Test.php @@ -1098,7 +1098,11 @@ public function test_runRawQuery(): void $x=$this->pdoOne->setFechMode(PDO::FETCH_CLASS,SomeClass::class)->runRawQuery('select ? as abc',['1'])[0]; self::assertInstanceOf(SomeClass::class,$x); self::assertEquals("1",$x->abc); - + } + public function test_camel():void { + self::assertEquals('CamelFormat',PdoOne::camelize('camel_format')); + self::assertEquals('CamelFormat',PdoOne::camelize('camel-format')); + self::assertEquals('CamelFormat',PdoOne::camelize('camelFormat')); } /**