Skip to content
This repository was archived by the owner on Aug 13, 2023. It is now read-only.

Commit 07a1f2f

Browse files
committed
new version
1 parent 4436d2c commit 07a1f2f

11 files changed

Lines changed: 37 additions & 30 deletions

File tree

demo/download.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
include_once __DIR__ . '/../vendor/autoload.php';
44

5-
$builder = new \Deimos\Builder\Builder();
6-
$helper = new \Deimos\Helper\Helper($builder);
5+
$helper = new \Deimos\Helper\Helper();
76

87
$name = $helper->str()->translit('MVC Example Администрирование локальных сетей.zip');
98

demo/send.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
include_once __DIR__ . '/../vendor/autoload.php';
44

5-
$builder = new \Deimos\Builder\Builder();
6-
$helper = new \Deimos\Helper\Helper($builder);
5+
$helper = new \Deimos\Helper\Helper();
76

87
$bytes = 0;
98
$bytesIterator = 0;

demo/test.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
include_once __DIR__ . '/../vendor/autoload.php';
44

5-
$builder = new \Deimos\Builder\Builder();
6-
$helper = new \Deimos\Helper\Helper($builder);
5+
$helper = new \Deimos\Helper\Helper();
76

87
var_dump($helper->arr()->get([
98
'name' => 'Max'

demo/upload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
if ($_SERVER['REQUEST_METHOD'] === 'POST')
1414
{
1515

16-
$helper = new \Deimos\Helper\Helper(new \Deimos\Builder\Builder());
16+
$helper = new \Deimos\Helper\Helper();
1717

1818
$files = $helper->uploads()->get('file');
1919

src/Helper/Helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Helper extends Builder
1919
*
2020
* @throws \InvalidArgumentException
2121
*/
22-
public function __construct(Builder $builder)
22+
public function __construct(Builder $builder = null)
2323
{
2424
if ($builder instanceof self)
2525
{

src/Helper/Helpers/File.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,6 @@ public function remove($path)
2727
return unlink($path);
2828
}
2929

30-
/**
31-
* @param string $path
32-
*
33-
* @return bool
34-
*
35-
* @deprecated use File->isFile OR Dir->isDir, as it slowly
36-
*/
37-
public function exists($path)
38-
{
39-
return file_exists($path);
40-
}
41-
4230
/**
4331
* @param string $path
4432
*

src/Helper/Helpers/Math.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
class Math extends AbstractHelper
88
{
99

10+
const PI = M_PI;
11+
const PI_2 = M_PI_2;
12+
const PI_4 = M_PI_4;
13+
1014
/**
1115
* @param $base
1216
*
@@ -25,7 +29,7 @@ public function sqr($base)
2529
*/
2630
public function pow($base, $exponent)
2731
{
28-
return pow($base, $exponent);
32+
return $base ** $exponent;
2933
}
3034

3135
/**
@@ -62,4 +66,4 @@ public function isEven($argument)
6266
return !($argument & 1);
6367
}
6468

65-
}
69+
}

src/Helper/Traits/Helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ trait Helper
2323
*
2424
* @throws \InvalidArgumentException
2525
*/
26-
protected final function helper()
26+
protected function helper()
2727
{
2828
if (!$this->helper)
2929
{
@@ -38,7 +38,7 @@ protected final function helper()
3838
*
3939
* @throws \InvalidArgumentException
4040
*/
41-
private function instanceHelper()
41+
protected function instanceHelper()
4242
{
4343
if (method_exists($this->builder, 'helper'))
4444
{

tests/Tests/ArrTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function testFindPath()
141141

142142
public function testSet()
143143
{
144-
$storage = ['a' => ['b' => 1]];
144+
$storage = ['a' => ['b' => 1, 'd' => range(1, 10)]];
145145

146146
$this->helper()->arr()->set($storage, 'a.b', 2);
147147
$this->helper()->arr()->set($storage, 'a.c', 1);
@@ -157,6 +157,11 @@ public function testSet()
157157
1
158158
);
159159

160+
$this->assertEquals(
161+
$this->helper()->arr()->get($storage, 'a.d[0]'),
162+
1
163+
);
164+
160165
$this->assertEquals(
161166
$this->helper()->arr()->get($storage, 'a.d.e.f.g.a.b'),
162167
1

tests/bootstrap.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,18 @@
66
$loader = require dirname(__DIR__) . '/vendor/autoload.php';
77

88
$loader->addPsr4('DeimosTest\\', 'tests/src/');
9+
10+
if (class_exists('\PHPUnit\Framework\TestCase'))
11+
{
12+
class TestCase extends \PHPUnit\Framework\TestCase
13+
{
14+
15+
}
16+
}
17+
else
18+
{
19+
class TestCase extends \PHPUnit_Framework_TestCase
20+
{
21+
22+
}
23+
}

0 commit comments

Comments
 (0)