Skip to content

Commit 9c28c13

Browse files
committed
init repo from toolkit str-utils,arr-utils,obj-utils
0 parents  commit 9c28c13

30 files changed

+4967
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.idea/
2+
.phpintel/
3+
!README.md
4+
!.gitkeep
5+
composer.lock
6+
*.swp
7+
*.log
8+
*.pid
9+
*.patch
10+
.DS_Store

.php_cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
$header = <<<'EOF'
4+
This file is part of toolkit/stdlib.
5+
6+
@author https://github.com/inhere
7+
@link https://github.com/php-toolkit/stdlib
8+
@license MIT
9+
EOF;
10+
11+
return PhpCsFixer\Config::create()
12+
->setRiskyAllowed(true)
13+
->setRules([
14+
'@PSR2' => true,
15+
'array_syntax' => [
16+
'syntax' => 'short'
17+
],
18+
'class_attributes_separation' => true,
19+
'declare_strict_types' => true,
20+
'global_namespace_import' => true,
21+
'header_comment' => [
22+
'comment_type' => 'PHPDoc',
23+
'header' => $header,
24+
'separate' => 'bottom'
25+
],
26+
'no_unused_imports' => true,
27+
'single_quote' => true,
28+
'standardize_not_equals' => true,
29+
])
30+
->setFinder(
31+
PhpCsFixer\Finder::create()
32+
// ->exclude('test')
33+
->exclude('runtime')
34+
->exclude('vendor')
35+
->in(__DIR__)
36+
)
37+
->setUsingCache(false);

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 inhere
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

composer.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "toolkit/stdlib",
3+
"type": "library",
4+
"description": "some stdlib tool library of the php",
5+
"keywords": [
6+
"library",
7+
"tool",
8+
"array",
9+
"object",
10+
"string",
11+
"php"
12+
],
13+
"homepage": "https://github.com/php-toolkit/stdlib",
14+
"license": "MIT",
15+
"authors": [
16+
{
17+
"name": "inhere",
18+
"email": "[email protected]",
19+
"homepage": "http://www.yzone.net/"
20+
}
21+
],
22+
"require": {
23+
"php": ">7.1.0",
24+
"ext-mbstring": "*"
25+
},
26+
"autoload": {
27+
"psr-4": {
28+
"Toolkit\\Stdlib\\": "src/"
29+
}
30+
},
31+
"suggest": {
32+
"inhere/php-validate": "Very lightweight data validate tool"
33+
}
34+
}

src/Arr.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/stdlib.
4+
*
5+
* @author https://github.com/inhere
6+
* @link https://github.com/php-toolkit/stdlib
7+
* @license MIT
8+
*/
9+
10+
namespace Toolkit\Stdlib;
11+
12+
use Toolkit\Stdlib\Arr\ArrayHelper;
13+
14+
/**
15+
* Class Arr
16+
* alias of the ArrayHelper
17+
*
18+
* @package Toolkit\Stdlib
19+
*/
20+
class Arr extends ArrayHelper
21+
{
22+
}

src/Arr/ArrBuffer.php

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/stdlib.
4+
*
5+
* @author https://github.com/inhere
6+
* @link https://github.com/php-toolkit/stdlib
7+
* @license MIT
8+
*/
9+
10+
namespace Toolkit\Stdlib\Arr;
11+
12+
/**
13+
* Class ArrBuffer
14+
*
15+
* @package Toolkit\Stdlib\Arr
16+
*/
17+
final class ArrBuffer
18+
{
19+
/**
20+
* @var string[]
21+
*/
22+
private $body = [];
23+
24+
/**
25+
* @var string
26+
*/
27+
private $delimiter = ''; // '/' ':'
28+
29+
/**
30+
* @param string $first
31+
*
32+
* @return ArrBuffer
33+
*/
34+
public static function new(string $first = ''): ArrBuffer
35+
{
36+
return new self($first);
37+
}
38+
39+
/**
40+
* constructor.
41+
*
42+
* @param string $content
43+
*/
44+
public function __construct(string $content = '')
45+
{
46+
if ($content) {
47+
$this->body[] = $content;
48+
}
49+
}
50+
51+
/**
52+
* @param string $content
53+
*/
54+
public function write(string $content): void
55+
{
56+
$this->body[] = $content;
57+
}
58+
59+
/**
60+
* @param string $content
61+
*/
62+
public function append(string $content): void
63+
{
64+
$this->write($content);
65+
}
66+
67+
/**
68+
* @param string $content
69+
*/
70+
public function prepend(string $content): void
71+
{
72+
array_unshift($this->body, $content);
73+
}
74+
75+
/**
76+
* clear
77+
*/
78+
public function clear(): void
79+
{
80+
$this->body = [];
81+
}
82+
83+
/**
84+
* @return string[]
85+
*/
86+
public function getBody(): array
87+
{
88+
return $this->body;
89+
}
90+
91+
/**
92+
* @param string[] $body
93+
*/
94+
public function setBody(array $body): void
95+
{
96+
$this->body = $body;
97+
}
98+
99+
/**
100+
* @return string
101+
*/
102+
public function toString(): string
103+
{
104+
return implode($this->delimiter, $this->body);
105+
}
106+
107+
/**
108+
* @return string
109+
*/
110+
public function __toString()
111+
{
112+
return $this->toString();
113+
}
114+
115+
/**
116+
* @return string
117+
*/
118+
public function getDelimiter(): string
119+
{
120+
return $this->delimiter;
121+
}
122+
123+
/**
124+
* @param string $delimiter
125+
*/
126+
public function setDelimiter(string $delimiter): void
127+
{
128+
$this->delimiter = $delimiter;
129+
}
130+
}

0 commit comments

Comments
 (0)