Skip to content

Commit 9f5a638

Browse files
committed
Initial import
1 parent f9327da commit 9f5a638

5 files changed

+61
-0
lines changed

composer.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "rkr/php-ioc-contract",
3+
"type": "library",
4+
"license": "MIT",
5+
"require": {
6+
"php": ">= 5.3"
7+
},
8+
"autoload": {
9+
"psr-4": {
10+
"Ioc\\": "src/"
11+
}
12+
}
13+
}

src/Container.php

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
namespace Ioc;
3+
4+
/**
5+
* Combines all interfaces
6+
*/
7+
interface Container extends ObjectFactory, InstanceContainer, MethodInvoker {
8+
}

src/InstanceContainer.php

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
namespace Ioc;
3+
4+
interface InstanceContainer {
5+
/**
6+
* Returns an instance of $className. Is no instance of $className exists, it will be created.
7+
*
8+
* @param string $className
9+
* @return object
10+
*/
11+
public function get($className);
12+
}

src/MethodInvoker.php

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
namespace Ioc;
3+
4+
interface MethodInvoker {
5+
/**
6+
* Invokes the callable $callable with the arguments $arguments. If arguments were missing in $arguments, the
7+
* method-invoker tries to fill the missing arguments by itself.
8+
*
9+
* @param $callable
10+
* @param array $arguments
11+
* @return mixed
12+
*/
13+
public function invoke($callable, array $arguments = array());
14+
}

src/ObjectFactory.php

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
namespace Ioc;
3+
4+
interface ObjectFactory {
5+
/**
6+
* The object-factory creates a class with the name $className and the __construct-arguments $arguments. If
7+
* arguments were missing in $arguments, the method-invoker tries to fill the missing arguments by itself.
8+
*
9+
* @param string $className
10+
* @param array $arguments
11+
* @return mixed
12+
*/
13+
public function create($className, array $arguments = array());
14+
}

0 commit comments

Comments
 (0)