Skip to content

Commit fa35199

Browse files
sobolevnasobolevna
authored andcommitted
Добавлено немного документации для среды разработки
0 parents  commit fa35199

File tree

20 files changed

+787
-0
lines changed

20 files changed

+787
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
vendor
2+
composer.lock
3+
.idea
4+

composer.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "phpixie/cli",
3+
"description": "CLI library for PHPixie",
4+
"keywords": ["console", "cli", "command line"],
5+
"homepage": "http://phpixie.com",
6+
"type": "library",
7+
"license": "BSD",
8+
"authors": [
9+
{
10+
"name": "Roman Tsiupa",
11+
"email": "[email protected]",
12+
"homepage": "http://dracony.org"
13+
}
14+
],
15+
"require": {
16+
"phpixie/slice": "~3.0"
17+
},
18+
"require-dev": {
19+
"phpixie/test": "~3.0"
20+
},
21+
"autoload": {
22+
"psr-4": {
23+
"PHPixie\\": "src/PHPixie",
24+
"PHPixie\\Tests\\": "tests/PHPixie/Tests"
25+
}
26+
},
27+
"extra": {
28+
"branch-alias": {
29+
"dev-master": "3.x-dev"
30+
}
31+
}
32+
}

phpunit.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<phpunit bootstrap="./tests/phpunit.php">
2+
<testsuites>
3+
<testsuite name="unit">
4+
<directory>./tests</directory>
5+
<exclude>./tests/PHPixie/Tests/ORM/Functional</exclude>
6+
</testsuite>
7+
<testsuite name="functional">
8+
<directory>./tests/PHPixie/Tests/ORM/Functional</directory>
9+
</testsuite>
10+
</testsuites>
11+
<filter>
12+
<whitelist>
13+
<directory suffix=".php">./src</directory>
14+
</whitelist>
15+
</filter>
16+
</phpunit>

src/PHPixie/CLI.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace PHPixie;
4+
5+
class CLI
6+
{
7+
/**
8+
* @var CLI\Builder
9+
*/
10+
protected $builder;
11+
12+
public function __construct($contextContainer = null)
13+
{
14+
$this->builder = $this->buildBuilder($contextContainer);
15+
}
16+
17+
/**
18+
*
19+
* @return \PHPixie\CLI\Context\SAPI
20+
*/
21+
public function context()
22+
{
23+
return $this->builder->context();
24+
}
25+
26+
public function buildSapiContext()
27+
{
28+
return $this->builder->buildSapiContext();
29+
}
30+
31+
/**
32+
*
33+
* @param type $contextContainer
34+
* @return \PHPixie\CLI\Builder
35+
*/
36+
protected function buildBuilder($contextContainer)
37+
{
38+
return new CLI\Builder($contextContainer);
39+
}
40+
}

src/PHPixie/CLI/Builder.php

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
3+
namespace PHPixie\CLI;
4+
5+
class Builder
6+
{
7+
/**
8+
*
9+
* @var \PHPixie\CLI\Context\Container\Implementation
10+
*/
11+
protected $contextContainer;
12+
13+
public function __construct($contextContainer = null)
14+
{
15+
$this->contextContainer = $contextContainer;
16+
}
17+
18+
/**
19+
*
20+
* @param string $resource
21+
* @return \PHPixie\CLI\Stream\Input
22+
*/
23+
public function inputStream($resource)
24+
{
25+
return new Stream\Input($resource);
26+
}
27+
28+
/**
29+
*
30+
* @param string $resource
31+
* @return \PHPixie\CLI\Stream\Output
32+
*/
33+
public function outputStream($resource)
34+
{
35+
return new Stream\Output($resource);
36+
}
37+
38+
/**
39+
*
40+
* @return \PHPixie\CLI\Context\SAPI
41+
*/
42+
public function context()
43+
{
44+
return $this->contextContainer()->cliContext();
45+
}
46+
47+
/**
48+
*
49+
* @return \PHPixie\CLI\Context\Container\Implementation
50+
*/
51+
public function contextContainer()
52+
{
53+
if($this->contextContainer === null) {
54+
$context = $this->buildSapiContext();
55+
$this->contextContainer = $this->buildContextContainer($context);
56+
}
57+
58+
return $this->contextContainer;
59+
}
60+
61+
/**
62+
*
63+
* @param \PHPixie\CLI\Context\SAPI $context
64+
* @return \PHPixie\CLI\Context\Container\Implementation
65+
*/
66+
public function buildContextContainer($context)
67+
{
68+
return new \PHPixie\CLI\Context\Container\Implementation($context);
69+
}
70+
71+
/**
72+
*
73+
* @return \PHPixie\CLI\Context\SAPI
74+
*/
75+
public function buildSapiContext()
76+
{
77+
return new Context\SAPI($this);
78+
}
79+
}

src/PHPixie/CLI/Context.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace PHPixie\CLI;
4+
5+
interface Context
6+
{
7+
public function inputStream();
8+
public function outputStream();
9+
public function errorStream();
10+
public function currentDirectory();
11+
public function arguments();
12+
public function setExitCode($exitCode);
13+
public function exitCode();
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace PHPixie\CLI\Context;
4+
5+
interface Container
6+
{
7+
public function cliContext();
8+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace PHPixie\CLI\Context\Container;
4+
5+
class Implementation implements \PHPixie\CLI\Context\Container
6+
{
7+
/**
8+
*
9+
* @var \PHPixie\CLI\Context\SAPI
10+
*/
11+
protected $cliContext;
12+
13+
/**
14+
*
15+
* @param \PHPixie\CLI\Context\SAPI $cliContext
16+
*/
17+
public function __construct($cliContext)
18+
{
19+
$this->cliContext = $cliContext;
20+
}
21+
22+
/**
23+
*
24+
* @return \PHPixie\CLI\Context\SAPI
25+
*/
26+
public function cliContext()
27+
{
28+
return $this->cliContext;
29+
}
30+
31+
public function setCliContext($cliContext)
32+
{
33+
return $this->cliContext = $cliContext;
34+
}
35+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace PHPixie\CLI\Context\Container;
4+
5+
interface Settable extends \PHPixie\CLI\Context\Container
6+
{
7+
public function setCliContext($cliContext);
8+
}

0 commit comments

Comments
 (0)