Skip to content

Commit 554d498

Browse files
abdussalam-alaliactions-user
authored andcommitted
Fix styling
1 parent 6e6be3a commit 554d498

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

.php-cs-fixer.cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"php":"8.1.0","version":"3.4.0","indent":" ","lineEnding":"\n","rules":{"blank_line_after_opening_tag":true,"braces":{"allow_single_line_anonymous_class_with_empty_body":true},"class_definition":{"space_before_parenthesis":true},"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":{"method":"one"}}},"hashes":{"src\/Interfaces\/ClassToBuildInterface.php":1998540425,"src\/Abstracts\/AbstractToBuild.php":851759240,"src\/Classes\/ClassToBuild.php":913908939,"tests\/BaseTest.php":3538535820,"tests\/Feature\/ExampleTest.php":4065595002,"src\/Interfaces\/ArabicDiffForHumansInterface.php":1279869002,"src\/Abstracts\/ArabicDiffForHumansAbstract.php":2655589807,"src\/Classes\/ArabicDiffForHumans.php":3215309222,"tests\/Feature\/ArabicDiffForHumansTest.php":754316182}}
1+
{"php":"8.1.0","version":"3.4.0","indent":" ","lineEnding":"\n","rules":{"blank_line_after_opening_tag":true,"braces":{"allow_single_line_anonymous_class_with_empty_body":true},"class_definition":{"space_before_parenthesis":true},"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":{"method":"one"}}},"hashes":{"src\/Interfaces\/ClassToBuildInterface.php":1998540425,"src\/Abstracts\/AbstractToBuild.php":851759240,"src\/Classes\/ClassToBuild.php":913908939,"tests\/BaseTest.php":3538535820,"tests\/Feature\/ExampleTest.php":4065595002,"src\/Interfaces\/ArabicDiffForHumansInterface.php":1279869002,"src\/Abstracts\/ArabicDiffForHumansAbstract.php":1208521234,"src\/Classes\/ArabicDiffForHumans.php":3685912262,"tests\/Feature\/ArabicDiffForHumansTest.php":754316182}}

src/Abstracts/ArabicDiffForHumansAbstract.php

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
*/
1111
abstract class ArabicDiffForHumansAbstract
1212
{
13-
1413
private $toDivideBy =
1514
[
1615
1, // seconds [0]
1716
60, // minute [1]
18-
60*60, // hours [2]
17+
60 * 60, // hours [2]
1918
60 * 60 * 24, // days [3]
2019
60 * 60 * 24 * 30, // months [4]
21-
60 * 60 * 24 * 365 // years [5]
20+
60 * 60 * 24 * 365, // years [5]
2221
];
22+
2323
/**
2424
*
2525
*
@@ -31,8 +31,9 @@ abstract class ArabicDiffForHumansAbstract
3131
*/
3232
protected function DiffValue($diff, $unit)
3333
{
34-
echo $this->toDivideBy[$unit-1]. '\n';
35-
return ( $diff / $this->toDivideBy[$unit-1]);
34+
echo $this->toDivideBy[$unit - 1]. '\n';
35+
36+
return ($diff / $this->toDivideBy[$unit - 1]);
3637
}
3738

3839
/**
@@ -58,16 +59,22 @@ protected function getDifference($timestamp)
5859
*/
5960
protected function unit($diff)
6061
{
61-
if ($diff < 60)
62-
return 1; // seconds
63-
if ($diff < 60 * 60)
64-
return 2; // minutes
65-
if ($diff < 24 * 60 * 60)
66-
return 3; // hours
67-
if ($diff < 24 * 60 * 60 * 30)
68-
return 4; //days
69-
if ($diff < 24 * 60 * 60 * 365)
70-
return 5; // months
62+
if ($diff < 60) {
63+
return 1;
64+
} // seconds
65+
if ($diff < 60 * 60) {
66+
return 2;
67+
} // minutes
68+
if ($diff < 24 * 60 * 60) {
69+
return 3;
70+
} // hours
71+
if ($diff < 24 * 60 * 60 * 30) {
72+
return 4;
73+
} //days
74+
if ($diff < 24 * 60 * 60 * 365) {
75+
return 5;
76+
} // months
77+
7178
return 6; //years
7279
}
7380

src/Classes/ArabicDiffForHumans.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ public function getFromDateString($dateString)
3838
public function get($timeStamp)
3939
{
4040
$diff = $this->getDifference($timeStamp);
41-
echo $diff; echo "\n";
41+
echo $diff;
42+
echo "\n";
4243
$unit = $this->unit($diff);
43-
echo $unit; echo "\n";
44+
echo $unit;
45+
echo "\n";
4446
$valueOfDifference = floor($this->DiffValue($diff, $unit));
4547
echo $valueOfDifference . "\n";
4648
$result = "";

0 commit comments

Comments
 (0)