orgupframework /Orgup/Common/Modifiers/Split.php

Language PHP Lines 67
MD5 Hash bfd2a1aae636902b3911f8b5c8af6da7 Estimated Cost $1,065 (why?)
Repository https://bitbucket.org/llxff/orgupframework.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
 * Created by JetBrains PhpStorm.
 * User: ll
 * Date: 26.11.11
 * Time: 16:13
 * To change this template use File | Settings | File Templates.
 */
namespace Orgup\Common\Modifiers;

use \Orgup\Common\Modifier;

class Split extends Modifier
{

    public $from;
    public $concat = ' ';
    public $fields;

    protected function createResult()
    {
        $result = '';

        $this->fields = $this->getFields();

        $fieldsCount = sizeof($this->fields);

        for($i = 0; $i < $fieldsCount; $i++)
        {
            $Route = $this->getRoute();
            $Route->set_object($this->object);
            $Route->Modify($this->reflectedProperty());
            $Route->suppress_warnings = $this->suppress_warnings;
            $Route->name = $this->fields[$i];
            $routeResult = trim($Route->getResult());
            $result .= $routeResult;

            $this->object->setCustomProperty($this->fields[$i], $routeResult, true);

            if($i < $fieldsCount - 1)
            {
                $result .= $this->concat;
            }
        }

        return $result;
    }

    private function getFields()
    {
        $fields = explode('|' , $this->fields);
        return $fields;
    }

    public function getRoute()
    {
        if($this->from == 'Post')
        {
            return new Post();
        }
        else
        {
            return new Get();
        }
    }
}
Back to Top