Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
stud-symfa
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Александр Плохих
stud-symfa
Commits
9c2a1d37
Commit
9c2a1d37
authored
11 months ago
by
Akex
Browse files
Options
Downloads
Patches
Plain Diff
add func search | add test data
parent
2a7f91b8
Branches
PTPS|Function_2
Branches containing commit
No related tags found
1 merge request
!12
Ptps|function 2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
public/public/Actions/IdSearchAction.php
+28
-0
28 additions, 0 deletions
public/public/Actions/IdSearchAction.php
public/public/TestData/TestData.php
+14
-1
14 additions, 1 deletion
public/public/TestData/TestData.php
public/public/index.php
+2
-1
2 additions, 1 deletion
public/public/index.php
with
44 additions
and
2 deletions
public/public/Actions/IdSearchAction.php
0 → 100644
+
28
−
0
View file @
9c2a1d37
<?php
namespace
App\Actions
;
class
IdSearchAction
{
/**
* Найдет элемент с указаным id
* @param array $array - массив, содержащий элементы со структурой
* [
* 'id' => 30,
* 'name' => 'Jhon',
* 'age' => 23,
* ]
* @param $id - ид искомого элемента
* @return array|null - найденный элемент/ вернет null при его отсутствии
*/
public
static
function
search
(
array
$array
,
$id
):
?array
{
foreach
(
$array
as
$item
){
if
(
$item
[
'id'
]
===
$id
){
return
$item
;
}
}
return
null
;
}
}
This diff is collapsed.
Click to expand it.
public/public/TestData/TestData.php
+
14
−
1
View file @
9c2a1d37
...
...
@@ -8,5 +8,18 @@ namespace App\TestData;
class
TestData
{
public
const
ARRAY_FOR_SEARCHING
=
[
[
'id'
=>
30
,
'name'
=>
'Sasha'
,
],
[
'id'
=>
542
,
'name'
=>
'Adlan'
,
],
[
'id'
=>
3234
,
'name'
=>
'Pavel'
,
],
];
}
This diff is collapsed.
Click to expand it.
public/public/index.php
+
2
−
1
View file @
9c2a1d37
...
...
@@ -2,6 +2,7 @@
require_once
__DIR__
.
'/../vendor/autoload.php'
;
use
App\Actions
/*placeholder for a class */
;
use
App\Actions
\IdSearchAction
;
use
App\TestData\TestData
;
var_dump
(
IdSearchAction
::
search
(
TestData
::
ARRAY_FOR_SEARCHING
));
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment