Skip to content

Commit

Permalink
Updating.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmatosbc committed Dec 23, 2024
1 parent eb62b14 commit 24bb172
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .phpcs-cache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"config":{"phpVersion":80226,"phpExtensions":"6444a8d24aa127a4fe13989038fc4447","tabWidth":4,"encoding":"utf-8","recordErrors":true,"annotations":true,"configData":[],"codeHash":"b5dc58ae9d1a395f86384fd9a1678bb4","rulesetHash":"670f8348153700c3a70fc6127ca0e484"},"\/home\/carlos\/Projects\/factory\/src\/Exceptions\/ClassNotFoundException.php":{"hash":"ef42127b99db182750f3cb885f5a00a233204","errors":[],"warnings":[],"metrics":{"Declarations and side effects mixed":{"values":{"no":1}},"PHP short open tag used":{"values":{"no":1}},"EOL char":{"values":{"\\n":1}},"Number of newlines at EOF":{"values":{"1":1}},"PHP closing tag at end of PHP-only file":{"values":{"no":1}},"Line length":{"values":{"80 or less":5}},"PHP keyword case":{"values":{"lower":3}},"Multiple statements on same line":{"values":{"no":1}},"One class per file":{"values":{"yes":1}},"Class defined in namespace":{"values":{"yes":1}},"PascalCase class name":{"values":{"yes":1}},"Class opening brace placement":{"values":{"new line":1}}},"errorCount":0,"warningCount":0,"fixableCount":0,"numTokens":23},"\/home\/carlos\/Projects\/factory\/src\/Exceptions\/ServiceNotFoundException.php":{"hash":"fd4d95418d462fa9339b8f96cf301a7533204","errors":[],"warnings":[],"metrics":{"Declarations and side effects mixed":{"values":{"no":1}},"PHP short open tag used":{"values":{"no":1}},"EOL char":{"values":{"\\n":1}},"Number of newlines at EOF":{"values":{"1":1}},"PHP closing tag at end of PHP-only file":{"values":{"no":1}},"Line length":{"values":{"80 or less":5}},"PHP keyword case":{"values":{"lower":3}},"Multiple statements on same line":{"values":{"no":1}},"One class per file":{"values":{"yes":1}},"Class defined in namespace":{"values":{"yes":1}},"PascalCase class name":{"values":{"yes":1}},"Class opening brace placement":{"values":{"new line":1}}},"errorCount":0,"warningCount":0,"fixableCount":0,"numTokens":23},"\/home\/carlos\/Projects\/factory\/src\/ServiceFactory.php":{"hash":"8af11ef2a53563eb49f1e8f2415d9a7b33204","errors":{"125":{"13":[{"message":"No blank line found after control structure","source":"Squiz.WhiteSpace.ControlStructureSpacing.NoLineAfterClose","listener":"PHP_CodeSniffer\\Standards\\Squiz\\Sniffs\\WhiteSpace\\ControlStructureSpacingSniff","severity":0,"fixable":true}]}},"warnings":[],"metrics":{"Declarations and side effects mixed":{"values":{"no":1}},"PHP short open tag used":{"values":{"no":1}},"EOL char":{"values":{"\\n":1}},"Number of newlines at EOF":{"values":{"1":1}},"PHP closing tag at end of PHP-only file":{"values":{"no":1}},"Line length":{"values":{"80 or less":100,"81-120":11}},"Line indent":{"values":{"spaces":104}},"PHP keyword case":{"values":{"lower":64}},"Multiple statements on same line":{"values":{"no":26}},"One class per file":{"values":{"yes":1}},"Class defined in namespace":{"values":{"yes":1}},"PascalCase class name":{"values":{"yes":1}},"Class opening brace placement":{"values":{"new line":1}},"PHP type case":{"values":{"lower":19}},"CamelCase method name":{"values":{"yes":6}},"Function opening brace placement":{"values":{"new line":6}},"Spaces after control structure open parenthesis":{"values":[12]},"Spaces before control structure close parenthesis":{"values":[12]},"Blank lines at start of control structure":{"values":[13]},"Blank lines at end of control structure":{"values":[13]},"Control structure defined inline":{"values":{"no":10}},"PHP constant case":{"values":{"lower":8}}},"errorCount":1,"warningCount":0,"fixableCount":1,"numTokens":870}}
{"config":{"phpVersion":80226,"phpExtensions":"6444a8d24aa127a4fe13989038fc4447","tabWidth":4,"encoding":"utf-8","recordErrors":true,"annotations":true,"configData":[],"codeHash":"b5dc58ae9d1a395f86384fd9a1678bb4","rulesetHash":"670f8348153700c3a70fc6127ca0e484"},"\/home\/carlos\/Projects\/factory\/src\/Exceptions\/ClassNotFoundException.php":{"hash":"011861a2c1e73e741c9a3ebc26e25d6f33204","errors":[],"warnings":[],"metrics":{"Declarations and side effects mixed":{"values":{"no":1}},"PHP short open tag used":{"values":{"no":1}},"EOL char":{"values":{"\\n":1}},"Number of newlines at EOF":{"values":{"1":1}},"PHP closing tag at end of PHP-only file":{"values":{"no":1}},"Line length":{"values":{"80 or less":9,"81-120":2}},"PHP keyword case":{"values":{"lower":3}},"Multiple statements on same line":{"values":{"no":1}},"One class per file":{"values":{"yes":1}},"Class defined in namespace":{"values":{"yes":1}},"PascalCase class name":{"values":{"yes":1}},"Class opening brace placement":{"values":{"new line":1}}},"errorCount":0,"warningCount":0,"fixableCount":0,"numTokens":46},"\/home\/carlos\/Projects\/factory\/src\/Exceptions\/ServiceNotFoundException.php":{"hash":"00acc7052806f62a3929cdbe663c3fa533204","errors":[],"warnings":[],"metrics":{"Declarations and side effects mixed":{"values":{"no":1}},"PHP short open tag used":{"values":{"no":1}},"EOL char":{"values":{"\\n":1}},"Number of newlines at EOF":{"values":{"1":1}},"PHP closing tag at end of PHP-only file":{"values":{"no":1}},"Line length":{"values":{"80 or less":10,"81-120":1}},"PHP keyword case":{"values":{"lower":3}},"Multiple statements on same line":{"values":{"no":1}},"One class per file":{"values":{"yes":1}},"Class defined in namespace":{"values":{"yes":1}},"PascalCase class name":{"values":{"yes":1}},"Class opening brace placement":{"values":{"new line":1}}},"errorCount":0,"warningCount":0,"fixableCount":0,"numTokens":46},"\/home\/carlos\/Projects\/factory\/src\/ServiceFactory.php":{"hash":"1d9cb1b08bc1d73bc5310cc458ebc0e733204","errors":{"160":{"13":[{"message":"No blank line found after control structure","source":"Squiz.WhiteSpace.ControlStructureSpacing.NoLineAfterClose","listener":"PHP_CodeSniffer\\Standards\\Squiz\\Sniffs\\WhiteSpace\\ControlStructureSpacingSniff","severity":0,"fixable":true}]}},"warnings":[],"metrics":{"Declarations and side effects mixed":{"values":{"no":1}},"PHP short open tag used":{"values":{"no":1}},"EOL char":{"values":{"\\n":1}},"Number of newlines at EOF":{"values":{"1":1}},"PHP closing tag at end of PHP-only file":{"values":{"no":1}},"Line length":{"values":{"80 or less":129,"81-120":17}},"Line indent":{"values":{"spaces":130}},"PHP keyword case":{"values":{"lower":70}},"Multiple statements on same line":{"values":{"no":29}},"One class per file":{"values":{"yes":1}},"Class defined in namespace":{"values":{"yes":1}},"PascalCase class name":{"values":{"yes":1}},"Class opening brace placement":{"values":{"new line":1}},"PHP type case":{"values":{"lower":19}},"CamelCase method name":{"values":{"yes":6}},"Function opening brace placement":{"values":{"new line":6}},"Spaces after control structure open parenthesis":{"values":[13]},"Spaces before control structure close parenthesis":{"values":[13]},"Blank lines at start of control structure":{"values":[15]},"Blank lines at end of control structure":{"values":[15]},"Control structure defined inline":{"values":{"no":12}},"PHP constant case":{"values":{"lower":8}}},"errorCount":1,"warningCount":0,"fixableCount":1,"numTokens":1094},"\/home\/carlos\/Projects\/factory\/src\/Conditions\/ConditionInterface.php":{"hash":"26dcd5f24a9d92a35ad0c5385425c43833188","errors":[],"warnings":[],"metrics":{"Declarations and side effects mixed":{"values":{"no":1}},"PHP short open tag used":{"values":{"no":1}},"EOL char":{"values":{"\\n":1}},"Number of newlines at EOF":{"values":{"1":1}},"PHP closing tag at end of PHP-only file":{"values":{"no":1}},"Line length":{"values":{"80 or less":23}},"Line indent":{"values":{"spaces":12}},"PHP keyword case":{"values":{"lower":6}},"Multiple statements on same line":{"values":{"no":3}},"One class per file":{"values":{"yes":1}},"Class defined in namespace":{"values":{"yes":1}},"PascalCase class name":{"values":{"yes":1}},"Class opening brace placement":{"values":{"new line":1}},"CamelCase method name":{"values":{"yes":2}},"PHP type case":{"values":{"lower":2}}},"errorCount":0,"warningCount":0,"fixableCount":0,"numTokens":110},"\/home\/carlos\/Projects\/factory\/src\/Conditions\/AndCondition.php":{"hash":"e69ce8ab29a2820cc1c8115a365cc47633188","errors":{"29":{"9":[{"message":"No blank line found after control structure","source":"Squiz.WhiteSpace.ControlStructureSpacing.NoLineAfterClose","listener":"PHP_CodeSniffer\\Standards\\Squiz\\Sniffs\\WhiteSpace\\ControlStructureSpacingSniff","severity":0,"fixable":true}]}},"warnings":[],"metrics":{"Declarations and side effects mixed":{"values":{"no":1}},"PHP short open tag used":{"values":{"no":1}},"EOL char":{"values":{"\\n":1}},"Number of newlines at EOF":{"values":{"1":1}},"PHP closing tag at end of PHP-only file":{"values":{"no":1}},"Line length":{"values":{"80 or less":28}},"Line indent":{"values":{"spaces":20}},"PHP keyword case":{"values":{"lower":15}},"Multiple statements on same line":{"values":{"no":7}},"One class per file":{"values":{"yes":1}},"Class defined in namespace":{"values":{"yes":1}},"PascalCase class name":{"values":{"yes":1}},"Class opening brace placement":{"values":{"new line":1}},"PHP type case":{"values":{"lower":3}},"Function opening brace placement":{"values":{"new line":2}},"CamelCase method name":{"values":{"yes":1}},"Spaces after control structure open parenthesis":{"values":[2]},"Spaces before control structure close parenthesis":{"values":[2]},"Blank lines at start of control structure":{"values":[2]},"Blank lines at end of control structure":{"values":[2]},"Control structure defined inline":{"values":{"no":2}},"PHP constant case":{"values":{"lower":2}}},"errorCount":1,"warningCount":0,"fixableCount":1,"numTokens":200},"\/home\/carlos\/Projects\/factory\/src\/Conditions\/NotCondition.php":{"hash":"ec181faf7a6ecb223ef9bbfa3faf8acc33188","errors":[],"warnings":[],"metrics":{"Declarations and side effects mixed":{"values":{"no":1}},"PHP short open tag used":{"values":{"no":1}},"EOL char":{"values":{"\\n":1}},"Number of newlines at EOF":{"values":{"1":1}},"PHP closing tag at end of PHP-only file":{"values":{"no":1}},"Line length":{"values":{"80 or less":21}},"Line indent":{"values":{"spaces":13}},"PHP keyword case":{"values":{"lower":10}},"Multiple statements on same line":{"values":{"no":5}},"One class per file":{"values":{"yes":1}},"Class defined in namespace":{"values":{"yes":1}},"PascalCase class name":{"values":{"yes":1}},"Class opening brace placement":{"values":{"new line":1}},"Function opening brace placement":{"values":{"new line":2}},"CamelCase method name":{"values":{"yes":1}},"PHP type case":{"values":{"lower":1}}},"errorCount":0,"warningCount":0,"fixableCount":0,"numTokens":123},"\/home\/carlos\/Projects\/factory\/src\/Conditions\/CachedCondition.php":{"hash":"e3969b8be705e14ac22e2084269c447833188","errors":{"31":{"13":[{"message":"Expected 0 spaces after opening bracket; newline found","source":"Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpenBrace","listener":"PHP_CodeSniffer\\Standards\\Squiz\\Sniffs\\WhiteSpace\\ControlStructureSpacingSniff","severity":0,"fixable":true}]}},"warnings":[],"metrics":{"Declarations and side effects mixed":{"values":{"no":1}},"PHP short open tag used":{"values":{"no":1}},"EOL char":{"values":{"\\n":1}},"Number of newlines at EOF":{"values":{"1":1}},"PHP closing tag at end of PHP-only file":{"values":{"no":1}},"Line length":{"values":{"80 or less":46}},"Line indent":{"values":{"spaces":38}},"PHP keyword case":{"values":{"lower":17}},"Multiple statements on same line":{"values":{"no":15}},"One class per file":{"values":{"yes":1}},"Class defined in namespace":{"values":{"yes":1}},"PascalCase class name":{"values":{"yes":1}},"Class opening brace placement":{"values":{"new line":1}},"PHP type case":{"values":{"lower":6}},"PHP constant case":{"values":{"lower":6}},"Function opening brace placement":{"values":{"new line":3}},"CamelCase method name":{"values":{"yes":2}},"Spaces after control structure open parenthesis":{"values":{"newline":1}},"Spaces before control structure close parenthesis":{"values":[1]},"Blank lines at start of control structure":{"values":[1]},"Blank lines at end of control structure":{"values":[1]},"Control structure defined inline":{"values":{"no":1}}},"errorCount":1,"warningCount":0,"fixableCount":1,"numTokens":325},"\/home\/carlos\/Projects\/factory\/src\/Conditions\/CallableCondition.php":{"hash":"c7b1d160baceffa5b465a7a2de05781633188","errors":[],"warnings":[],"metrics":{"Declarations and side effects mixed":{"values":{"no":1}},"PHP short open tag used":{"values":{"no":1}},"EOL char":{"values":{"\\n":1}},"Number of newlines at EOF":{"values":{"1":1}},"PHP closing tag at end of PHP-only file":{"values":{"no":1}},"Line length":{"values":{"80 or less":27}},"Line indent":{"values":{"spaces":19}},"PHP keyword case":{"values":{"lower":14}},"Multiple statements on same line":{"values":{"no":7}},"One class per file":{"values":{"yes":1}},"Class defined in namespace":{"values":{"yes":1}},"PascalCase class name":{"values":{"yes":1}},"Class opening brace placement":{"values":{"new line":1}},"PHP type case":{"values":{"lower":5}},"Function opening brace placement":{"values":{"new line":3}},"CamelCase method name":{"values":{"yes":2}}},"errorCount":0,"warningCount":0,"fixableCount":0,"numTokens":177},"\/home\/carlos\/Projects\/factory\/src\/Conditions\/OrCondition.php":{"hash":"d7eac08ebf37debb12b9bf1ce122812133188","errors":{"29":{"9":[{"message":"No blank line found after control structure","source":"Squiz.WhiteSpace.ControlStructureSpacing.NoLineAfterClose","listener":"PHP_CodeSniffer\\Standards\\Squiz\\Sniffs\\WhiteSpace\\ControlStructureSpacingSniff","severity":0,"fixable":true}]}},"warnings":[],"metrics":{"Declarations and side effects mixed":{"values":{"no":1}},"PHP short open tag used":{"values":{"no":1}},"EOL char":{"values":{"\\n":1}},"Number of newlines at EOF":{"values":{"1":1}},"PHP closing tag at end of PHP-only file":{"values":{"no":1}},"Line length":{"values":{"80 or less":28}},"Line indent":{"values":{"spaces":20}},"PHP keyword case":{"values":{"lower":15}},"Multiple statements on same line":{"values":{"no":7}},"One class per file":{"values":{"yes":1}},"Class defined in namespace":{"values":{"yes":1}},"PascalCase class name":{"values":{"yes":1}},"Class opening brace placement":{"values":{"new line":1}},"PHP type case":{"values":{"lower":3}},"Function opening brace placement":{"values":{"new line":2}},"CamelCase method name":{"values":{"yes":1}},"Spaces after control structure open parenthesis":{"values":[2]},"Spaces before control structure close parenthesis":{"values":[2]},"Blank lines at start of control structure":{"values":[2]},"Blank lines at end of control structure":{"values":[2]},"Control structure defined inline":{"values":{"no":2}},"PHP constant case":{"values":{"lower":2}}},"errorCount":1,"warningCount":0,"fixableCount":1,"numTokens":199},"\/home\/carlos\/Projects\/factory\/src\/Conditions\/AbstractCondition.php":{"hash":"5fbfcbf346d3748b5231fcb1516bf57033188","errors":[],"warnings":[],"metrics":{"Declarations and side effects mixed":{"values":{"no":1}},"PHP short open tag used":{"values":{"no":1}},"EOL char":{"values":{"\\n":1}},"Number of newlines at EOF":{"values":{"1":1}},"PHP closing tag at end of PHP-only file":{"values":{"no":1}},"Line length":{"values":{"80 or less":20}},"Line indent":{"values":{"spaces":12}},"PHP keyword case":{"values":{"lower":10}},"Multiple statements on same line":{"values":{"no":4}},"One class per file":{"values":{"yes":1}},"Class defined in namespace":{"values":{"yes":1}},"PascalCase class name":{"values":{"yes":1}},"Class opening brace placement":{"values":{"new line":1}},"PHP type case":{"values":{"lower":3}},"Function opening brace placement":{"values":{"new line":2}},"CamelCase method name":{"values":{"yes":1}}},"errorCount":0,"warningCount":0,"fixableCount":0,"numTokens":111}}
7 changes: 4 additions & 3 deletions src/Conditions/CachedCondition.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ public function __construct(ConditionInterface $condition, int $ttl)
public function evaluate(): bool
{
$now = time();

// If we have a cached result and it hasn't expired
if ($this->cachedResult !== null &&
$this->cachedAt !== null &&
if (
$this->cachedResult !== null &&
$this->cachedAt !== null &&
$now - $this->cachedAt < $this->ttl
) {
return $this->cachedResult;
Expand Down
2 changes: 1 addition & 1 deletion src/Conditions/ConditionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/**
* Interface for service conditions.
*
*
* Conditions are used to determine whether a service can be instantiated.
* They can be simple callables or complex compositions using decorators.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ClassNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/**
* Exception thrown when attempting to register a service with a non-existent class.
*
*
* This exception is thrown by the ServiceFactory when register() is called with a
* class name that does not exist or cannot be autoloaded.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ServiceNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/**
* Exception thrown when attempting to create a service that has not been registered.
*
*
* This exception is thrown by the ServiceFactory when create() is called with a
* service name that was not previously registered using register().
*/
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/**
* A flexible service container that supports conditional service instantiation.
*
*
* This container allows registering services with multiple conditions that must be met
* before the service can be instantiated. Each service can have zero or more conditions,
* and all conditions must evaluate to true for the service to be created.
Expand Down

0 comments on commit 24bb172

Please sign in to comment.